Tune this "contains" query in Oracle 11g EE 11.2.0.3.0
I have a query like below. It runs for ever. The size of this table is not very big, it has around 30 millions rows. The owner column is very selective, and I've added "owner' column in the "filter by" clause of the domain index against description. Do you have any recommendation how I can tune this query? Any help would be greatly appreciated.
select count(*) from items s where contains(s.description, '%111%' ) > 0 and s.owner = 1234;
Thanks.
You need to use SDATA to access the owner column through the index. You may also get better performance on your wildcard searches by using a wordlist with attributes as shown below. Please see the demonstration below.
SCOTT@orcl_11gR2> create table items as
2 select object_id as owner, object_name as description
3 from all_objects
4 /
Table created.
SCOTT@orcl_11gR2> insert into items values (1234, 'A111B')
2 /
1 row created.
SCOTT@orcl_11gR2> select count(*) from items
2 /
COUNT(*)
75048
1 row selected.
SCOTT@orcl_11gR2> begin
2 ctx_ddl.create_preference('mywordlist', 'BASIC_WORDLIST');
3 ctx_ddl.set_attribute('mywordlist','PREFIX_INDEX','TRUE');
4 ctx_ddl.set_attribute('mywordlist','PREFIX_MIN_LENGTH', 1);
5 ctx_ddl.set_attribute('mywordlist','SUBSTRING_INDEX', 'YES');
6 ctx_ddl.set_attribute('mywordlist', 'wildcard_maxterms', 50000) ;
7 end;
8 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> create index items_idx
2 on items (description)
3 indextype is ctxsys.context
4 filter by owner
5 parameters ('wordlist mywordlist')
6 /
Index created.
SCOTT@orcl_11gR2> set autotrace on explain
SCOTT@orcl_11gR2> select count(*) from items
2 where contains (description, '%111% and (sdata (owner = 1234))') > 0
3 /
COUNT(*)
1
1 row selected.
Execution Plan
Plan hash value: 1238254566
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 29 | 12 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 29 | | |
|* 2 | DOMAIN INDEX | ITEMS_IDX | 39 | 1131 | 4 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("CTXSYS"."CONTAINS"("DESCRIPTION",'%111% and (sdata
(owner = 1234))')>0)
Note
- dynamic sampling used for this statement (level=2)
SCOTT@orcl_11gR2>
Similar Messages
-
How to tune self join query in Oracle 11g
Oracle & SQL new to me,and I'm still in learning phase.
Could you please help me to tune below oracle query?? This table contains ~95 lac records and it takes 1 hour to retrieve data using this query.
Your suggestions/comments/help will be appreciated.
Thanks in advance.
SELECT A.CNO AS CNO, A.FNO AS FNO, A.CID AS CID, A.IID AS IID
FROM CAC_LKP A, (SELECT C_DATE, CNO, FNO
FROM (SELECT MAX(CAC_LKP.C_DATE) AS C_DATE, CAC_LKP.CNO AS CNO, CAC_LKP.FNO AS FNO
FROM CAC_LKP
WHERE ACTIVE = 'Y' GROUP BY CNO, FNO)) B
WHERE A.C_DATE = B.C_DATE
AND A.CNO = B.CNO
AND A.FNO = B.FNO
AND A.ACTIVE = 'Y'
Primary key is defied over combination of c_date,iid,active.
Edited by: 1009236 on Jun 1, 2013 12:52 AM>
SELECT A.CNO AS CNO,
A.FNO AS FNO,
A.CID AS CID,
A.IID AS IID
FROM CAC_LKP A,
SELECT C_DATE,
CNO,
FNO
FROM
SELECT MAX(CAC_LKP.C_DATE) AS C_DATE,
CAC_LKP.CNO AS CNO,
CAC_LKP.FNO AS FNO
FROM CAC_LKP
WHERE ACTIVE = 'Y'
GROUP BY CNO, FNO
) B
WHERE A.C_DATE = B.C_DATE AND
A.CNO = B.CNO AND
A.FNO = B.FNO AND
A.ACTIVE = 'Y';Hi,
Before even starting to see why there is a performance problem, I think you should consider the fact that there is logical problem in your WHERE clause. According to what you mentioned the primary key is composed of *(c_date, iid, active)* yet iid is absent in both the global query's WHERE clause and also that of the subquery.
Consequently the (aggregate) rows in the subquery will not be linked based on a correct logic to the external query.
Regards,
Dariyoosh -
Please help me what other way i can tune this select query..
Hello Guru,
I have a select query which retrieve data from 10 tables and around 4 tables having 2-4 Lac record and rest are having 80,000 - 1 Lac record.
It is taking around 7-8 seconds to fetch 55000 record.
I was strictly told by the client that i should not use HINTS in my query. My query is below. Please help me what other way i can tune this select query..
select
CT.CUST_ID
,CT.ROMANISED_SURNAME
,CT.SURNAME
,CT.ROMANISED_GIVEN_NAME
,CT.GIVEN_NAME
,CT.ROMANISED_MIDDLE_NAME
,CT.MIDDLE_NAME
,CT.ROMANISED_NAME_SUFFIX
,CT.NAME_SUFFIX
,CT.ROMANISED_TITLE
,CT.TITLE
,CT.ROMANISED_NAME_INITIALS
,CT.NAME_INITIALS
,CT.NAME_TEXT
,CT.CUST_JRNY_ID
,RK.REMARK_TYPE
,RK.REMARK_ID+CT.CUST_ID as REMARK_ID
,RK.REMARK_STATUS
,RK.REMARK_TEXT
,RK.HOST_ONLY_IND
,RK.SUPERVISORY_IND
,RK.CUST_COMM_IND
,RK.REMARK_SEQ
,RK.REMARK_CODE
,RK.DEFAULT_CUST_REL_IND
,RK.DEFAULT_FLIGHT_SEG_REL_IND
,RK.IATA_CODE
,RK.ICAO_CODE
,CJ.RECORD_LOCATOR "SITA_RECORD_LOCATOR"
,Cjv.Record_Locator "ORIGINATOR_RECORD_LOCATOR"
,FS.TRAVELLING_GROUP_CODE
,CG.GROUP_NAME
FROM FLIGHT_LEG FL
,CUST_FLIGHT_LEG CFL
,CUST CT
,CUST_REMARK CTR
,REMARK RK
,FLIGHT_SEG_FLIGHT_LEG FSFL
,FLIGHT_SEG FS
,CUST_JRNY CJ
,CUST_JRNY_VERSION CJV
,CUST_GROUP CG
WHERE FL.OPR_FLIGHT_NUMBER = 1--I_OPR_FLIGHT_NUMBER
and FL.HISTORY_VERSION_NUMBER = 0
and FL.DEPARTURE_STATION_CODE = 'DEL'--I_DEPARTURE_STATION_CODE
and FL.DEPARTURE_DATETIME = TO_DATE('10-DEC-2012 18.45.00', 'DD-MON-YYYY HH24.MI.SS')
and FL.OPR_SERVICE_PROVIDER_CODE= 'AI'--i_opr_service_provider_code
and FL.OPR_FLIGHT_SUFFIX = 'A'--NVL(I_OPR_FLIGHT_SUFFIX, FL.OPR_FLIGHT_SUFFIX)
AND FL.FLIGHT_LEG_ID = CFL.FLIGHT_LEG_ID
AND CFL.CUST_ID = CT.CUST_ID
AND FL.FLIGHT_LEG_ID=FSFL.FLIGHT_LEG_ID
AND FSFL.FLIGHT_SEG_ID=FS.FLIGHT_SEG_ID
AND CT.CUST_ID = CTR.CUST_ID(+)
AND CTR.REMARK_ID = RK.REMARK_ID(+)
AND FL.CUST_JRNY_ID = CJ.CUST_JRNY_ID
and CJ.CUST_JRNY_ID = CJV.CUST_JRNY_ID
AND CG.CUST_JRNY_ID(+) = CT.CUST_JRNY_ID
AND CFL.HISTORY_VERSION_NUMBER = 0
AND CT.HISTORY_VERSION_NUMBER = 0
AND NVL(CTR.HISTORY_VERSION_NUMBER,0) = 0
AND NVL(RK.HISTORY_VERSION_NUMBER,0) = 0
AND FS.HISTORY_VERSION_NUMBER = 0
AND FSFL.HISTORY_VERSION_NUMBER = 0
-- AND CJ.HISTORY_VERSION_NUMBER = 0
and CJV.VERSION_NUMBER = 0 --- Need to check
AND NVL(CG.HISTORY_VERSION_NUMBER,0) = 0
order by CT.CUST_JRNY_ID,CT.CUST_ID;
The Tables having record:
select COUNT(*) from FLIGHT_LEG -----241756
select COUNT(*) from CUST_FLIGHT_LEG---632585
select COUNT(*) from CUST---240015
select COUNT(*) from CUST_REMARK---73724
select COUNT(*) from REMARK---73654
select COUNT(*) from FLIGHT_SEG_FLIGHT_LEG---241789
select COUNT(*) from FLIGHT_SEG----260004
select COUNT(*) from CUST_JRNY----74288
select COUNT(*) from CUST_JRNY_VERSION----74477
select COUNT(*) from CUST_GROUP----55819
Thanks,
HP..Plan hash value: 3771714931
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 10239 | 2949K| | 7515 (1)| 00:01:31 | | |
| 1 | SORT ORDER BY | | 10239 | 2949K| 3160K| 7515 (1)| 00:01:31 | | |
|* 2 | HASH JOIN | | 10239 | 2949K| | 6864 (1)| 00:01:23 | | |
| 3 | PARTITION HASH ALL | | 73687 | 1079K| | 417 (1)| 00:00:06 | 1 | 512 |
|* 4 | TABLE ACCESS FULL | CUST_JRNY_VERSION | 73687 | 1079K| | 417 (1)| 00:00:06 | 1 | 512 |
|* 5 | HASH JOIN | | 10239 | 2799K| | 6445 (1)| 00:01:18 | | |
| 6 | PARTITION HASH ALL | | 73654 | 863K| | 178 (1)| 00:00:03 | 1 | 512 |
| 7 | TABLE ACCESS FULL | CUST_JRNY | 73654 | 863K| | 178 (1)| 00:00:03 | 1 | 512 |
|* 8 | FILTER | | | | | | | | |
|* 9 | HASH JOIN RIGHT OUTER | | 10239 | 2679K| | 6267 (1)| 00:01:16 | | |
| 10 | PARTITION HASH ALL | | 55315 | 756K| | 137 (1)| 00:00:02 | 1 | 512 |
| 11 | TABLE ACCESS FULL | CUST_GROUP | 55315 | 756K| | 137 (1)| 00:00:02 | 1 | 512 |
|* 12 | FILTER | | | | | | | | |
|* 13 | HASH JOIN OUTER | | 10240 | 2540K| 2056K| 6129 (1)| 00:01:14 | | |
|* 14 | FILTER | | | | | | | | |
|* 15 | HASH JOIN RIGHT OUTER | | 10242 | 1930K| | 5531 (1)| 00:01:07 | | |
| 16 | INDEX FAST FULL SCAN | CUST_REMARK_PK | 73677 | 935K| | 190 (0)| 00:00:03 | | |
|* 17 | HASH JOIN | | 10257 | 1802K| | 5339 (1)| 00:01:05 | | |
|* 18 | HASH JOIN | | 10257 | 701K| | 3516 (1)| 00:00:43 | | |
|* 19 | HASH JOIN | | 3963 | 220K| | 2476 (1)| 00:00:30 | | |
|* 20 | HASH JOIN | | 3963 | 181K| | 1300 (1)| 00:00:16 | | |
| 21 | PARTITION HASH ALL | | 3963 | 131K| | 728 (1)| 00:00:09 | 1 | 512 |
|* 22 | TABLE ACCESS FULL | FLIGHT_LEG | 3963 | 131K| | 728 (1)| 00:00:09 | 1 | 512 |
|* 23 | INDEX FAST FULL SCAN| FLIGHT_SEG_FLIGHT_LEG_PK | 240K| 3059K| | 571 (1)| 00:00:07 | | |
| 24 | PARTITION HASH ALL | | 259K| 2531K| | 1175 (1)| 00:00:15 | 1 | 512 |
|* 25 | TABLE ACCESS FULL | FLIGHT_SEG | 259K| 2531K| | 1175 (1)| 00:00:15 | 1 | 512 |
| 26 | PARTITION HASH ALL | | 631K| 8011K| | 1037 (1)| 00:00:13 | 1 | 512 |
|* 27 | TABLE ACCESS FULL | CUST_FLIGHT_LEG | 631K| 8011K| | 1037 (1)| 00:00:13 | 1 | 512 |
| 28 | PARTITION HASH ALL | | 239K| 25M| | 1822 (1)| 00:00:22 | 1 | 512 |
|* 29 | TABLE ACCESS FULL | CUST | 239K| 25M| | 1822 (1)| 00:00:22 | 1 | 512 |
| 30 | PARTITION HASH ALL | | 73623 | 4385K| | 243 (1)| 00:00:03 | 1 | 512 |
| 31 | TABLE ACCESS FULL | REMARK | 73623 | 4385K| | 243 (1)| 00:00:03 | 1 | 512 |
Predicate Information (identified by operation id):
2 - access("CJ"."CUST_JRNY_ID"="CJV"."CUST_JRNY_ID")
4 - filter("CJV"."VERSION_NUMBER"=0)
5 - access("FL"."CUST_JRNY_ID"="CJ"."CUST_JRNY_ID")
8 - filter(NVL("CG"."HISTORY_VERSION_NUMBER",0)=0)
9 - access("CG"."CUST_JRNY_ID"(+)="CT"."CUST_JRNY_ID")
12 - filter(NVL("RK"."HISTORY_VERSION_NUMBER",0)=0)
13 - access("CTR"."REMARK_ID"="RK"."REMARK_ID"(+))
14 - filter(NVL("CTR"."HISTORY_VERSION_NUMBER",0)=0)
15 - access("CT"."CUST_ID"="CTR"."CUST_ID"(+))
17 - access("CFL"."CUST_ID"="CT"."CUST_ID")
18 - access("FL"."FLIGHT_LEG_ID"="CFL"."FLIGHT_LEG_ID")
19 - access("FSFL"."FLIGHT_SEG_ID"="FS"."FLIGHT_SEG_ID")
20 - access("FL"."FLIGHT_LEG_ID"="FSFL"."FLIGHT_LEG_ID")
22 - filter("FL"."DEPARTURE_STATION_CODE"='DEL' AND "FL"."DEPARTURE_DATETIME"=TO_DATE(' 2012-12-10 18:45:00', 'syyyy-mm-dd
hh24:mi:ss') AND "FL"."OPR_SERVICE_PROVIDER_CODE"='AI' AND "FL"."OPR_FLIGHT_NUMBER"=1 AND "FL"."OPR_FLIGHT_SUFFIX"='A' AND
"FL"."HISTORY_VERSION_NUMBER"=0)
23 - filter("FSFL"."HISTORY_VERSION_NUMBER"=0)
25 - filter("FS"."HISTORY_VERSION_NUMBER"=0)
27 - filter("CFL"."HISTORY_VERSION_NUMBER"=0)
29 - filter("CT"."HISTORY_VERSION_NUMBER"=0) -
We use Oracle 11g DB on windows2008R2.
We wrote very long and heavy SELECT SQL query usign several table join and sub-queries and it take very long time to get result.
We did SQL statement tuning as much as we can do so far. ( I will get the Execution Plan and ADDM, etc access right)
I today notice about Parallel query function.
Where could I write parallel hint phrases in very long SELECT SQL query ?
In each selected tables like below ?
/sample in Oracle Doc/
SELECT /*+ PARALLEL(employees 4) PARALLEL(departments 4)
USE_HASH(employees) ORDERED */ MAX(salary), AVG(salary)
FROM employees, departments
WHERE employees.department_id = departments.department_id
GROUP BY employees.department_id;You need to be careful with some of the examples in the docs. The example you quote includes an unnecessary join. Before considering parallel query, it should have been re-written to this:
SELECT MAX(salary), AVG(salary)
FROM employees
WHERE department_id is not null
GROUP BYdepartment_id;
Later versions of the CBO may do this re-write for you, but it is important to understand why the SQL is inefficient before throwing parallel servers at it. Are you sure that all your joins are actually necessary? (I know you are just going to say "yes", but you might want to think about it first.) -
Hi all,
Query executes for more 1.5 hours. fetches the data from a remote database. more than million records.
any suggestions to tune the query?
Explain Plan
CREATE TABLE STATEMENT ALL_ROWSCost: 3,777 Bytes: 1,161,660 Cardinality: 15,285
5 LOAD AS SELECT hcl_delta_TMP_2
4 NESTED LOOPS Cost: 3,768 Bytes: 1,161,660 Cardinality: 15,285
2 SORT UNIQUE Cost: 1 Bytes: 693 Cardinality: 99
1 INDEX FULL SCAN INDEX (UNIQUE) DELTA_REASON_CODES_PK Cost: 1 Bytes: 693 Cardinality: 99
3 REMOTE REMOTE SERIAL_FROM_REMOTE PSM_LIB_LOG_R RMDB Cost: 74 Bytes: 10,626 Cardinality: 154
Query:
CREATE TABLE hcl_delta_tmp_2 AS
SELECT
'hcl' AS heritage,
load_dt,
process_dt,
update_status_cd,
loan_number,
lib_date,
lib_time,
lib_code,
lib_user_id,
lib_log_key_date_time
FROM psm_lib_log_r@RMDB a
WHERE a.process_dt >= TO_DATE('01/01/2010','MM/DD/YYYY') AND
a.update_status_cd NOT IN( 'P' ) AND
a.lib_code IN
SELECT TRIM(delta_code) AS delta_code
FROM delta_reason_codes
Delta code column is a primary key in table delta_reason_codes: DELTA_REASON_CODES_PKVersion : Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
thanks.I think I am getting conflicting information about how many rows are in the remote table.
First we read that the remote table has more than 10 million records and then we read that applying this where clause WHERE a.process_dt >= TO_DATE('01/01/2010','MM/DD/YYYY')
AND a.update_status_cd NOT IN ('P') Results in that will be too many records, more than 10 millions.What are the total number of rows in the remote table?
How many rows match the date condition by itself?
How many match the status code condition by itself?
How many match the lib_code condition by itself?
How many rows match all conditions (the number returned by the query)?
Sorry, but I am just trying clear up any confusion here. -
How to tune this SQL Query?
Hi all expert out there,
I am using Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, OLAP, Data Mining and Real Application Testing options.
I have this ERP 11i query took 3-4hours to execute. can anyone help to have a look at the Query so make it more faster? I am already out of my idea of solving this. Kindly helpzzz...
SELECT
/*+ first_rows(1)*/
hou.name "OU" ,-- e.g. Seagate Technology USOP1 ,
mc.description,
oel.ordered_item "Product Part Number",
oeh.order_number "Order Num",
hp.party_name "Bill To Cust Name",
hcsu.location "Ship To Cust Num",
oel.line_number || '.' || oel.shipment_number "Order Line Num",
ft.nls_territory "Ship To Country",
mc.segment7 "designapplication",
ccm.formattedcapacity||'GB' "Capacity",
oel.attribute1 "Order Category",
oel.Subinventory "Subinventory",
to_char(oel.actual_shipment_date,'MM/DD/YYYY DY') "Shipment Date",
NVL(oel.shipped_quantity,0) "Net Units"
FROM
oe_order_headers_all oeh
,oe_order_lines_all oel
,apps.hz_parties hp
,apps.hz_cust_accounts hca
,apps.hz_cust_site_uses_all hcsu
,apps.hz_cust_acct_sites_all hcas
, apps.seaeng_ccfamilymodelinfo ccm
,apps.hz_party_sites hps
,apps.fnd_territories ft
,apps.hz_locations hl
,apps.hr_organization_units hou
,apps.mtl_parameters mp
,apps.mtl_item_categories mic
,apps.mtl_categories_b mc
,apps.fnd_lookup_values flv
WHERE
oeh.header_id = oel.header_id
AND oel.flow_status_code = 'CLOSED'
AND oeh.invoice_to_org_id = hcsu.site_use_id
AND hl.country = ft.territory_code
AND hps.location_id = hl.location_id
AND hcas.party_site_id = hps.party_site_id
AND hcsu.cust_acct_site_id = hcas.cust_acct_site_id
AND hcas.cust_account_id = hca.cust_account_id
AND hca.party_id = hp.party_id
AND oeh.org_id = hou.organization_id
AND oel.ship_from_org_id = mp.organization_id
AND oel.inventory_item_id = mic.inventory_item_id
AND mic.category_id = mc.category_id
AND mic.category_set_id = 4
AND mc.description = ccm.stmodelnumber
AND flv.lookup_code = hca.sales_channel_code
AND flv.lookup_type = 'SALES_CHANNEL'
AND mc.segment7 IN ('PSG','ESG','NSG')
AND flv.lookup_code NOT IN ('RTL','AD-RTL','EU')
AND oel.attribute1 IN ('NB','NBEOL','NBSEA')
AND oel.subinventory IN ('KFGI','AFGI','SFGIF','FGIF')
AND hou.organization_id = 189
AND trunc(oel.actual_shipment_date) between TO_DATE('01-Jan-2009','DD-MON-YYYY') and TO_DATE('31-JAN-2009','DD-MON-YYYY')
regards,
Lygine
Edited by: user8989062 on Jun 7, 2010 6:39 PM5) The TKPROF output for this statement looks like the following:
SELECT
/*+ first_rows(1)*/
hou.name "OU" ,-- e.g. Seagate Technology USOP1 ,
mc.description,
oel.ordered_item "Product Part Number",
oeh.order_number "Order Num",
hp.party_name "Bill To Cust Name",
hcsu.location "Ship To Cust Num",
oel.line_number || '.' || oel.shipment_number "Order Line Num",
ft.nls_territory "Ship To Country",
mc.segment7 "designapplication",
ccm.formattedcapacity||'GB' "Capacity",
oel.attribute1 "Order Category",
oel.Subinventory "Subinventory",
to_char(oel.actual_shipment_date,'MM/DD/YYYY DY') "Shipment Date",
NVL(oel.shipped_quantity,0) "Net Units"
FROM
oe_order_headers_all oeh
,oe_order_lines_all oel
,apps.hz_parties hp
,apps.hz_cust_accounts hca
,apps.hz_cust_site_uses_all hcsu
,apps.hz_cust_acct_sites_all hcas
, apps.seaeng_ccfamilymodelinfo ccm
,apps.hz_party_sites hps
,apps.fnd_territories ft
,apps.hz_locations hl
,apps.hr_organization_units hou
,apps.mtl_parameters mp
,apps.mtl_item_categories mic
,apps.mtl_categories_b mc
,apps.fnd_lookup_values flv
WHERE
oeh.header_id = oel.header_id
AND oel.flow_status_code = 'CLOSED'
AND oeh.invoice_to_org_id = hcsu.site_use_id
AND hl.country = ft.territory_code
AND hps.location_id = hl.location_id
AND hcas.party_site_id = hps.party_site_id
AND hcsu.cust_acct_site_id = hcas.cust_acct_site_id
AND hcas.cust_account_id = hca.cust_account_id
AND hca.party_id = hp.party_id
AND oeh.org_id = hou.organization_id
AND oel.ship_from_org_id = mp.organization_id
AND oel.inventory_item_id = mic.inventory_item_id
AND mic.category_id = mc.category_id
AND mic.category_set_id = 4
AND mc.description = ccm.stmodelnumber
AND flv.lookup_code = hca.sales_channel_code
AND flv.lookup_type = 'SALES_CHANNEL'
AND mc.segment7 IN ('PSG','ESG','NSG')
AND flv.lookup_code NOT IN ('RTL','AD-RTL','EU')
AND oel.attribute1 IN ('NB','NBEOL','NBSEA')
AND oel.subinventory IN ('KFGI','AFGI','SFGIF','FGIF')
AND hou.organization_id = 189
AND trunc(oel.actual_shipment_date) between TO_DATE('01-Jan-2009','DD-MON-YYYY') and TO_DATE('31-JAN-2009','DD-MON-YYYY')
call count cpu elapsed disk query current rows
Parse 1 0.79 0.79 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 7 22.23 240.85 19781 536082 0 592
total 9 23.02 241.64 19781 536082 0 592
Misses in library cache during parse: 1
Optimizer mode: FIRST_ROWS
Parsing user id: 173
Rows Row Source Operation
592 NESTED LOOPS (cr=536082 pr=19781 pw=0 time=240822989 us)
592 NESTED LOOPS (cr=534885 pr=19776 pw=0 time=239960969 us)
592 NESTED LOOPS (cr=533688 pr=19776 pw=0 time=239902332 us)
594 NESTED LOOPS (cr=532493 pr=19776 pw=0 time=239811721 us)
594 NESTED LOOPS (cr=531892 pr=19776 pw=0 time=239794703 us)
594 NESTED LOOPS (cr=530693 pr=19772 pw=0 time=239325284 us)
594 NESTED LOOPS (cr=529498 pr=19770 pw=0 time=239152940 us)
594 NESTED LOOPS (cr=527709 pr=19766 pw=0 time=236850676 us)
594 NESTED LOOPS (cr=525920 pr=19764 pw=0 time=235640068 us)
2990 NESTED LOOPS (cr=516943 pr=19688 pw=0 time=195144282 us)
2990 NESTED LOOPS (cr=516936 pr=19688 pw=0 time=195120297 us)
2990 NESTED LOOPS (cr=510806 pr=19682 pw=0 time=194678671 us)
3000 HASH JOIN (cr=504799 pr=19669 pw=0 time=193829763 us)
3000 NESTED LOOPS (cr=472280 pr=360 pw=0 time=49218087 us)
1 NESTED LOOPS (cr=1029 pr=34 pw=0 time=1745829 us)
1 TABLE ACCESS BY INDEX ROWID HR_ALL_ORGANIZATION_UNITS_TL (cr=424 pr=25 pw=0 time=1361442 us)
1 INDEX UNIQUE SCAN HR_ALL_ORGANIZATION_UNTS_TL_PK (cr=423 pr=25 pw=0 time=1361397 us)(object id 44637)
1 TABLE ACCESS BY INDEX ROWID HR_ALL_ORGANIZATION_UNITS (cr=605 pr=9 pw=0 time=384370 us)
1 INDEX UNIQUE SCAN HR_ORGANIZATION_UNITS_PK (cr=1 pr=0 pw=0 time=27 us)(object id 43498)
3000 TABLE ACCESS BY INDEX ROWID OE_ORDER_LINES_ALL (cr=471251 pr=326 pw=0 time=47466249 us)
156922 INDEX RANGE SCAN OE_ORDER_LINES_N20 (cr=420 pr=7 pw=0 time=787919 us)(object id 37005064)
263469 TABLE ACCESS FULL MTL_ITEM_CATEGORIES (cr=32519 pr=19309 pw=0 time=144242743 us)
2990 TABLE ACCESS BY INDEX ROWID MTL_CATEGORIES_B (cr=6007 pr=13 pw=0 time=843569 us)
3000 INDEX UNIQUE SCAN MTL_CATEGORIES_B_U1 (cr=3007 pr=2 pw=0 time=162636 us)(object id 37199)
2990 TABLE ACCESS BY INDEX ROWID SEAENG_CCFAMILYMODELINFO (cr=6130 pr=6 pw=0 time=437784 us)
2990 INDEX UNIQUE SCAN SEAENG_CCFAMILYMODELINFO_U1 (cr=2997 pr=0 pw=0 time=52872 us)(object id 35838918)
2990 INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=7 pr=0 pw=0 time=16332 us)(object id 37657)
594 TABLE ACCESS BY INDEX ROWID OE_ORDER_HEADERS_ALL (cr=8977 pr=76 pw=0 time=40491633 us)
2990 INDEX UNIQUE SCAN OE_ORDER_HEADERS_U1 (cr=5987 pr=45 pw=0 time=2504442 us)(object id 41952)
594 TABLE ACCESS BY INDEX ROWID HZ_CUST_SITE_USES_ALL (cr=1789 pr=2 pw=0 time=1208576 us)
594 INDEX UNIQUE SCAN HZ_CUST_SITE_USES_U1 (cr=1195 pr=1 pw=0 time=105934 us)(object id 25124976)
594 TABLE ACCESS BY INDEX ROWID HZ_CUST_ACCT_SITES_ALL (cr=1789 pr=4 pw=0 time=2300224 us)
594 INDEX UNIQUE SCAN HZ_CUST_ACCT_SITES_U1 (cr=1195 pr=2 pw=0 time=152238 us)(object id 25124996)
594 TABLE ACCESS BY INDEX ROWID HZ_PARTY_SITES (cr=1195 pr=2 pw=0 time=170875 us)
594 INDEX UNIQUE SCAN HZ_PARTY_SITES_U1 (cr=601 pr=1 pw=0 time=104550 us)(object id 25124993)
594 TABLE ACCESS BY INDEX ROWID HZ_LOCATIONS (cr=1199 pr=4 pw=0 time=467329 us)
594 INDEX UNIQUE SCAN HZ_LOCATIONS_U1 (cr=601 pr=0 pw=0 time=57749 us)(object id 25124992)
594 TABLE ACCESS BY INDEX ROWID FND_TERRITORIES (cr=601 pr=0 pw=0 time=15562 us)
594 INDEX UNIQUE SCAN FND_TERRITORIES_U1 (cr=7 pr=0 pw=0 time=6492 us)(object id 33083)
592 TABLE ACCESS BY INDEX ROWID HZ_CUST_ACCOUNTS (cr=1195 pr=0 pw=0 time=88925 us)
594 INDEX UNIQUE SCAN HZ_CUST_ACCOUNTS_U1 (cr=601 pr=0 pw=0 time=27607 us)(object id 81600)
592 INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=1197 pr=0 pw=0 time=56714 us)(object id 32878)
592 TABLE ACCESS BY INDEX ROWID HZ_PARTIES (cr=1197 pr=5 pw=0 time=860140 us)
592 INDEX UNIQUE SCAN HZ_PARTIES_U1 (cr=599 pr=0 pw=0 time=51136 us)(object id 25126074)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 7 0.00 0.00
row cache lock 1 0.00 0.00
gc current block 2-way 24112 0.00 19.28
gc cr grant 2-way 406 0.00 0.19
db file sequential read 441 0.09 14.11
gc cr block 2-way 284 0.00 0.23
gc cr block busy 147 0.19 9.59
gc current block congested 2 0.00 0.00
gc cr multi block request 13079 0.00 3.98
SQL*Net message from client 7 0.27 1.87
gc cr failure 39 0.00 0.02
cr request retry 39 0.98 38.27
SQL*Net more data to client 12 0.00 0.00
db file scattered read 2446 0.13 132.58
gc cr disk read 5 0.00 0.00
********************************************************************************6) The DBMS_XPLAN.DISPLAY_CURSOR output:
SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
SQL_ID b8pfhfxscqn1m, child number 0
SELECT /*+ gather_plan_statistics */ hou.name "OU" ,-- e.g. Seagate Technology USOP1 , mc.descript
oeh.order_number "Order Num", hp.party_name "Bill To Cust Name", hcsu.location "Ship To Cust Num",
Num", ft.nls_territory "Ship To Country", mc.segment7 "designapplication", ccm.formattedcapacity
oel.Subinventory "Subinventory", to_char(oel.actual_shipment_date,'MM/DD/YYYY DY') "Shipment Date",
oe_order_headers_all oeh ,oe_order_lines_all oel ,apps.hz_parties hp ,apps.hz_cust
,apps.hz_cust_acct_sites_all hcas , apps.seaeng_ccfamilymodelinfo ccm ,apps.hz_party_sites hps
,apps.hr_organization_units hou ,apps.mtl_paramete
Plan hash value: 414863479
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads | O
| 1 | NESTED LOOPS | | 1 | 1 | 592 |00:02:25.13 | 535K| 57267 | |
| 2 | NESTED LOOPS | | 1 | 1 | 592 |00:02:24.22 | 533K| 57185 |
| 3 | NESTED LOOPS | | 1 | 1 | 592 |00:02:24.15 | 532K| 57183 |
| 4 | NESTED LOOPS | | 1 | 1 | 594 |00:02:24.00 | 531K| 57171 |
| 5 | NESTED LOOPS | | 1 | 1 | 594 |00:02:23.98 | 530K| 57170 |
| 6 | NESTED LOOPS | | 1 | 1 | 594 |00:02:23.49 | 529K| 57129 |
| 7 | NESTED LOOPS | | 1 | 1 | 594 |00:02:23.08 | 528K| 57096 |
| 8 | NESTED LOOPS | | 1 | 1 | 594 |00:02:22.51 | 526K| 57031 | |
| 9 | NESTED LOOPS | | 1 | 1 | 594 |00:02:21.79 | 524K| 56968 | |
| 10 | NESTED LOOPS | | 1 | 1 | 2990 |00:02:09.65 | 515K| 55703 |
| 11 | NESTED LOOPS | | 1 | 1 | 2990 |00:02:09.62 | 515K| 55703 |
| 12 | NESTED LOOPS | | 1 | 1 | 2990 |00:02:08.47 | 509K| 55599 |
|* 13 | HASH JOIN | | 1 | 2 | 3000 |00:02:07.88 | 503K| 55516 | 974K
| 14 | NESTED LOOPS | | 1 | 2 | 3000 |00:01:39.07 | 471K| 23025 |
| 15 | NESTED LOOPS | | 1 | 1 | 1 |00:00:00.01 | 4 | 0 |
| 16 | TABLE ACCESS BY INDEX ROWID| HR_ALL_ORGANIZATION_UNITS_TL | 1 | 1 | 1 |00:00
|* 17 | INDEX UNIQUE SCAN | HR_ALL_ORGANIZATION_UNTS_TL_PK | 1 | 1 | 1 |00:00:00.0
|* 18 | TABLE ACCESS BY INDEX ROWID| HR_ALL_ORGANIZATION_UNITS | 1 | 1 | 1 |00:00:
|* 19 | INDEX UNIQUE SCAN | HR_ORGANIZATION_UNITS_PK | 1 | 1 | 1 |00:00:00.01
|* 20 | TABLE ACCESS BY INDEX ROWID | OE_ORDER_LINES_ALL | 1 | 2 | 3000 |00:01
|* 21 | INDEX RANGE SCAN | OE_ORDER_LINES_N20 | 1 | 47575 | 156K|00:00:01.76 | 420
|* 22 | TABLE ACCESS FULL | MTL_ITEM_CATEGORIES | 1 | 96977 | 263K|00:00:28.49
|* 23 | TABLE ACCESS BY INDEX ROWID | MTL_CATEGORIES_B | 3000 | 1 | 2990 |00:00:0
|* 24 | INDEX UNIQUE SCAN | MTL_CATEGORIES_B_U1 | 3000 | 1 | 3000 |00:00:00.21
| 25 | TABLE ACCESS BY INDEX ROWID | SEAENG_CCFAMILYMODELINFO | 2990 | 1 | 2990 |
|* 26 | INDEX UNIQUE SCAN | SEAENG_CCFAMILYMODELINFO_U1 | 2990 | 1 | 2990 |00:00:
|* 27 | INDEX UNIQUE SCAN | MTL_PARAMETERS_U1 | 2990 | 1 | 2990 |00:00:00.02 |
|* 28 | TABLE ACCESS BY INDEX ROWID | OE_ORDER_HEADERS_ALL | 2990 | 1 | 594 |00:00:
|* 29 | INDEX UNIQUE SCAN | OE_ORDER_HEADERS_U1 | 2990 | 1 | 2990 |00:00:04.29 |
| 30 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_SITE_USES_ALL | 594 | 1 | 594 |00:00:
|* 31 | INDEX UNIQUE SCAN | HZ_CUST_SITE_USES_U1 | 594 | 1 | 594 |00:00:00.31 |
| 32 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCT_SITES_ALL | 594 | 1 | 594 |00:00:
|* 33 | INDEX UNIQUE SCAN | HZ_CUST_ACCT_SITES_U1 | 594 | 1 | 594 |00:00:00.23 |
| 34 | TABLE ACCESS BY INDEX ROWID | HZ_PARTY_SITES | 594 | 1 | 594 |00:00:0
|* 35 | INDEX UNIQUE SCAN | HZ_PARTY_SITES_U1 | 594 | 1 | 594 |00:00:00.17 | 601
| 36 | TABLE ACCESS BY INDEX ROWID | HZ_LOCATIONS | 594 | 1 | 594 |00:00:00.4
|* 37 | INDEX UNIQUE SCAN | HZ_LOCATIONS_U1 | 594 | 1 | 594 |00:00:00.17 |
| 38 | TABLE ACCESS BY INDEX ROWID | FND_TERRITORIES | 594 | 1 | 594 |00:00:00
|* 39 | INDEX UNIQUE SCAN | FND_TERRITORIES_U1 | 594 | 1 | 594 |00:00:00.02
|* 40 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCOUNTS | 594 | 1 | 592 |00:00:0
|* 41 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 | 594 | 1 | 594 |00:00:00.04 |
|* 42 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U1 | 592 | 1 | 592 |00:00:00.06 |
| 43 | TABLE ACCESS BY INDEX ROWID | HZ_PARTIES | 592 | 1 | 592 |00:00:00.91 |
|* 44 | INDEX UNIQUE SCAN | HZ_PARTIES_U1 | 592 | 1 | 592 |00:00:00.40 | 599
Predicate Information (identified by operation id):
13 - access("OEL"."INVENTORY_ITEM_ID"="MIC"."INVENTORY_ITEM_ID")
17 - access("HAOTL"."ORGANIZATION_ID"=189 AND "HAOTL"."LANGUAGE"=USERENV('LANG'))
filter(DECODE("HR_SECURITY"."VIEW_ALL"(),'Y','TRUE',"HR_SECURITY"."SHOW_RECORD"('HR_ALL_ORGAN
18 - filter("HAO"."BUSINESS_GROUP_ID"=DECODE("HR_GENERAL"."GET_XBG_PROFILE"(),'Y',"HAO"."BUSINESS_
19 - access("HAO"."ORGANIZATION_ID"=189)
20 - filter(("OEL"."FLOW_STATUS_CODE"='CLOSED' AND INTERNAL_FUNCTION("OEL"."ATTRIBUTE1") AND INTER
21 - access("OEL"."SYS_NC00342$">=TO_DATE(' 2009-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "O
'syyyy-mm-dd hh24:mi:ss'))
22 - filter("MIC"."CATEGORY_SET_ID"=4)
23 - filter(("MC"."DESCRIPTION" IS NOT NULL AND INTERNAL_FUNCTION("MC"."SEGMENT7")))
24 - access("MIC"."CATEGORY_ID"="MC"."CATEGORY_ID")
26 - access("MC"."DESCRIPTION"="CCM"."STMODELNUMBER")
27 - access("OEL"."SHIP_FROM_ORG_ID"="MP"."ORGANIZATION_ID")
28 - filter("OEH"."ORG_ID"=189)
29 - access("OEH"."HEADER_ID"="OEL"."HEADER_ID")
31 - access("OEH"."INVOICE_TO_ORG_ID"="HCSU"."SITE_USE_ID")
33 - access("HCSU"."CUST_ACCT_SITE_ID"="HCAS"."CUST_ACCT_SITE_ID")
35 - access("HCAS"."PARTY_SITE_ID"="HPS"."PARTY_SITE_ID")
37 - access("HPS"."LOCATION_ID"="HL"."LOCATION_ID")
39 - access("HL"."COUNTRY"="FT"."TERRITORY_CODE")
40 - filter(("HCA"."SALES_CHANNEL_CODE"<>'RTL' AND "HCA"."SALES_CHANNEL_CODE"<>'AD-RTL' AND "HCA".
41 - access("HCAS"."CUST_ACCOUNT_ID"="HCA"."CUST_ACCOUNT_ID")
42 - access("FLV"."LOOKUP_TYPE"='SALES_CHANNEL' AND "FLV"."LOOKUP_CODE"="HCA"."SALES_CHANNEL_CODE"
filter(("FLV"."LOOKUP_CODE"<>'RTL' AND "FLV"."LOOKUP_CODE"<>'AD-RTL' AND "FLV"."LOOKUP_CODE"<
44 - access("HCA"."PARTY_ID"="HP"."PARTY_ID")
90 rows selected.
{code} &nbs -
How to write this sql query to oracle
Hi sir,
i am using one query in my sql stored procedure that is:
select @maxtime=CONVERT(Time,Out_Time+DATEADD(n,60,0)) from shift where Shift_Code = @ShiftCode
so here i am getting this value 01/01/1900 12:00 AM
the same i used in oracle my query is :
to_char(Out_Time,'1900-01-01' + 0/(24*60),'DD/MM/YYYY HH:MI AM')
INTO v_maxtime
FROM shift
WHERE Shift_Code = v_ShiftCode;
but getting error that is: Encountered the symbol INTO when expecting one of the following :=(%;
am i doing any thing wrong.
thanksAPC wrote:
The error you're getting is a syntax error. In this case because you've mangled the TO_CHAR syntax. Alas I cannot give you the correct version because I cannot unpick what you're trying to do with that statement.
It would be easier if you expalined what business logic you're trying to implement instead of asking us to interpret a piece of shonky SQL.It's yet another of the OP's questions about how to do DATEs in Oracle (so many threads it can get very confusing - even though the OP has been asked to stick to one thread!).
The code looks like it's based on the answer I gave here:
How to get exact query of sql in oracle?
but clearly he doesn't understand the basic syntax of Oracle or the datatypes he's using. Sometimes you just have to give up... (I know I have) -
Dear All,
i have a below create statement query in my Oracle Database - sql developer, when i tried this getting with the exception " 00907. 00000 - "missing right parenthesis"
CREATE TABLE FQ01_AA_FUTURE_INSTALLMENTS_M1 ( RECORD_ID VARCHAR (35),
mv_seq INT (4),
sv_seq INT (4),
PAY_TYPE VARCHAR (30),
PAY_PROP VARCHAR (30),
PAY_PROP_AMT FLOAT (30),
PAY_METHOD VARCHAR (30),
PAY_AMT FLOAT (30),
JB_DATE_IMPORT TIMESTAMP)
Is there any mistake on the above query, please update me....
Thanks
karthihi,
you can't determine digit for int
and I think you should replace float with number and varchar with varchar2
CREATE TABLE FQ01_AA_FUTURE_INSTALLMENTS_M1 ( RECORD_ID VARCHAR (35),
mv_seq number (4),
sv_seq number (4),
PAY_TYPE VARCHAR (30),
PAY_PROP VARCHAR (30),
PAY_PROP_AMT FLOAT (30),
PAY_METHOD VARCHAR (30),
PAY_AMT FLOAT (30),
JB_DATE_IMPORT TIMESTAMP)
Regards -
Help tune this monster query please
Hi, I have a query that runs for a long time. Its a system generated query but I need to improve its performance. I have enough indexes on the tables. Here is the query, its explain plan and the tkprof:
The QUERY
SELECT FD.FORM_ID, FD.FIELD_NAME, FD.FIELD_TEXT, FD.OPTION_TEXT, FD.OPTION_TYPE, FD.FIELD_ORDER, FD.LIST_ORDER,
FD.MULTIPLE_ANSWER, FD.FIELD_INSTANCE, NVL(AD.APPS,0) APPS
FROM (
SELECT FIELD_NAME, FIELD_VALUE, INSTANCE, COUNT(0) APPS
FROM APPLICATION_DATA AD
WHERE APPLICATION_ID IN (
SELECT A.APPLICATION_ID
FROM APPLICATIONS A
WHERE A.DELETED = 0 AND DECODE(A.TRAY,'Incomplete','Incomplete','Complete') = 'Complete' AND A.JOB_ID IN (
SELECT JOB_ID
FROM JOBS J
WHERE J.ACCOUNT_ID IN (
SELECT ACCOUNT_ID
FROM AGENCY_ACCOUNTS CONNECT BY ACCOUNT_ID = PRIOR AGENCY_ID START WITH ACCOUNT_ID = J.ACCOUNT_ID ) ) AND A.ACCOUNT_ID IN (
SELECT ACCOUNT_ID
FROM AGENCY_ACCOUNTS CONNECT BY ACCOUNT_ID = PRIOR AGENCY_ID START WITH ACCOUNT_ID = 113346 ) AND FIELD_NAME IN (
SELECT FIELD_NAME FROM APPLICATION_FIELDS
WHERE FIELD_TYPE IN ('Checkbox','Radio','Select','SelectM', 'RadioHoriz','RadioPara') ) )
GROUP BY FIELD_NAME, FIELD_VALUE, INSTANCE ) AD, (
SELECT AF.FORM_ID, AF.FIELD_NAME, AF.FIELD_TEXT, AFO.OPTION_TEXT, AFO.OPTION_TYPE, AF.FIELD_ORDER, AFO.LIST_ORDER,
DECODE(AF.FIELD_TYPE,'Checkbox',1,'SelectM',1,0) MULTIPLE_ANSWER, AF.FIELD_INSTANCE
FROM APPLICATION_FIELDS AF, APPLICATION_FIELD_OPTIONS AFO, JOB_FORMS JF
WHERE AFO.FIELD_NAME = AF.FIELD_NAME AND AFO.FORM_ID = AF.FORM_ID AND JF.FORM_ID = AF.FORM_ID AND AF.FIELD_TYPE IN
('Checkbox','Radio','Select','SelectM', 'RadioHoriz','RadioPara') AND JF.JOB_ID IN (
SELECT JOB_ID
FROM JOBS J
WHERE J.ACCOUNT_ID IN (
SELECT ACCOUNT_ID
FROM AGENCY_ACCOUNTS CONNECT BY ACCOUNT_ID = PRIOR AGENCY_ID START WITH ACCOUNT_ID = 113346 ) ) ) FD
WHERE AD.FIELD_NAME = FD.FIELD_NAME AND AD.FIELD_VALUE = FD.OPTION_TEXT AND AD.INSTANCE = FD.FIELD_INSTANCE
GROUP BY FD.FORM_ID, FD.FIELD_NAME, FD.FIELD_TEXT, FD.OPTION_TEXT, FD.OPTION_TYPE, FD.FIELD_ORDER, FD.LIST_ORDER,
FD.MULTIPLE_ANSWER, FD.FIELD_INSTANCE, NVL(AD.APPS,0)
ORDER BY FD.FORM_ID ASC, FD.FIELD_ORDER ASCEXPLAIN PLAN OUTPUT
PLAN_TABLE_OUTPUT
Plan hash value: 3519364953
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 120 | 763 (2)| 00:00:10 |
| 1 | SORT GROUP BY | | 1 | 120 | 763 (2)| 00:00:10 |
| 2 | VIEW | | 1 | 120 | 762 (1)| 00:00:10 |
| 3 | HASH GROUP BY | | 1 | 220 | 762 (1)| 00:00:10 |
|* 4 | FILTER | | | | | |
|* 5 | TABLE ACCESS BY INDEX ROWID | APPLICATION_DATA | 1 | 45 | 6 (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
| 6 | NESTED LOOPS | | 40 | 8800 | 486 (2)| 00:00:06 |
|* 7 | HASH JOIN | | 60 | 10500 | 125 (4)| 00:00:02 |
|* 8 | HASH JOIN | | 60 | 7320 | 53 (6)| 00:00:01 |
| 9 | NESTED LOOPS | | 11 | 297 | 9 (12)| 00:00:01 |
| 10 | VIEW | VW_NSO_3 | 3 | 15 | 5 (0)| 00:00:01 |
| 11 | HASH UNIQUE | | 3 | 69 | | |
| 12 | TABLE ACCESS BY INDEX ROWID | JOBS | 3 | 30 | 3 (0)| 00:00:01 |
| 13 | NESTED LOOPS | | 3 | 69 | 5 (0)| 00:00:01 |
| 14 | VIEW | VW_NSO_1 | 1 | 13 | 2 (0)| 00:00:01 |
|* 15 | CONNECT BY WITH FILTERING | | | | | |
| 16 | TABLE ACCESS BY INDEX ROWID | AGENCY_ACCOUNTS | | | | |
PLAN_TABLE_OUTPUT
|* 17 | INDEX UNIQUE SCAN | AGENCY_ACCOUNTS_ACCOUNT_ID | 1 | 5 | 1 (0)| 00:00:01 |
| 18 | NESTED LOOPS | | | | | |
| 19 | BUFFER SORT | | | | | |
| 20 | CONNECT BY PUMP | | | | | |
| 21 | TABLE ACCESS BY INDEX ROWID| AGENCY_ACCOUNTS | 1 | 10 | 2 (0)| 00:00:01 |
|* 22 | INDEX UNIQUE SCAN | AGENCY_ACCOUNTS_ACCOUNT_ID | 1 | | 1 (0)| 00:00:01 |
|* 23 | TABLE ACCESS FULL | AGENCY_ACCOUNTS | 1 | 10 | 2 (0)| 00:00:01 |
|* 24 | INDEX RANGE SCAN | JOBS_ACCOUNT_ID | 3 | | 1 (0)| 00:00:01 |
|* 25 | INDEX RANGE SCAN | JOBS_FORMS_JID_FID | 4 | 88 | 1 (0)| 00:00:01 |
|* 26 | TABLE ACCESS FULL | APPLICATION_FIELDS | 3579 | 332K| 43 (3)| 00:00:01 |
| 27 | TABLE ACCESS FULL | APPLICATION_FIELD_OPTIONS | 32897 | 1702K| 72 (3)| 00:00:01 |
PLAN_TABLE_OUTPUT
|* 28 | INDEX RANGE SCAN | IDX$$_B8D40001 | 4 | | 3 (0)| 00:00:01 |
|* 29 | FILTER | | | | | |
| 30 | MERGE JOIN CARTESIAN | | 3 | 225 | 11 (0)| 00:00:01 |
| 31 | NESTED LOOPS | | 1 | 53 | 6 (0)| 00:00:01 |
| 32 | NESTED LOOPS | | 1 | 40 | 4 (0)| 00:00:01 |
|* 33 | TABLE ACCESS BY INDEX ROWID | APPLICATIONS | 1 | 30 | 3 (0)| 00:00:01 |
|* 34 | INDEX UNIQUE SCAN | APPS_APP_ID | 1 | | 2 (0)| 00:00:01 |
| 35 | TABLE ACCESS BY INDEX ROWID | JOBS | 18780 | 183K| 1 (0)| 00:00:01 |
|* 36 | INDEX UNIQUE SCAN | JOBS_JOB_ID | 1 | | 0 (0)| 00:00:01 |
|* 37 | VIEW | VW_NSO_2 | 1 | 13 | 2 (0)| 00:00:01 |
|* 38 | CONNECT BY WITH FILTERING | | | | | |
PLAN_TABLE_OUTPUT
| 39 | TABLE ACCESS BY INDEX ROWID | AGENCY_ACCOUNTS | | | | |
|* 40 | INDEX UNIQUE SCAN | AGENCY_ACCOUNTS_ACCOUNT_ID | 1 | 5 | 1 (0)| 00:00:01 |
| 41 | NESTED LOOPS | | | | | |
| 42 | BUFFER SORT | | | | | |
| 43 | CONNECT BY PUMP | | | | | |
| 44 | TABLE ACCESS BY INDEX ROWID | AGENCY_ACCOUNTS | 1 | 10 | 2 (0)| 00:00:01 |
|* 45 | INDEX UNIQUE SCAN | AGENCY_ACCOUNTS_ACCOUNT_ID | 1 | | 1 (0)| 00:00:01 |
|* 46 | TABLE ACCESS FULL | AGENCY_ACCOUNTS | 1 | 10 | 2 (0)| 00:00:01 |
| 47 | BUFFER SORT | | 3 | 66 | 9 (0)| 00:00:01 |
| 48 | INLIST ITERATOR | | | | | |
|* 49 | INDEX RANGE SCAN | IDX$$_91CA0001 | 3 | 66 | 5 (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
|* 50 | FILTER | | | | | |
|* 51 | CONNECT BY WITH FILTERING | | | | | |
| 52 | TABLE ACCESS BY INDEX ROWID | AGENCY_ACCOUNTS | | | | |
|* 53 | INDEX UNIQUE SCAN | AGENCY_ACCOUNTS_ACCOUNT_ID | 1 | 5 | 1 (0)| 00:00:01 |
| 54 | NESTED LOOPS | | | | | |
| 55 | BUFFER SORT | | | | | |
| 56 | CONNECT BY PUMP | | | | | |
| 57 | TABLE ACCESS BY INDEX ROWID | AGENCY_ACCOUNTS | 1 | 10 | 2 (0)| 00:00:01 |
|* 58 | INDEX UNIQUE SCAN | AGENCY_ACCOUNTS_ACCOUNT_ID | 1 | | 1 (0)| 00:00:01 |
|* 59 | TABLE ACCESS FULL | AGENCY_ACCOUNTS | 1 | 10 | 2 (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
4 - filter( EXISTS (SELECT 0 FROM "APPLICATIONS" "A","JOBS" "SYS_ALIAS_1", (SELECT "ACCOUNT_ID" "$nso_col_1"
FROM "AGENCY_ACCOUNTS" "AGENCY_ACCOUNTS" WHERE "ACCOUNT_ID"=NULL) "VW_NSO_2","APPLICATION_FIELDS"
"APPLICATION_FIELDS" WHERE EXISTS (SELECT 0 FROM "AGENCY_ACCOUNTS" "AGENCY_ACCOUNTS" WHERE "ACCOUNT_ID"=NULL AND
("ACCOUNT_ID"=:B1)) AND ("FIELD_TYPE"='Checkbox' OR "FIELD_TYPE"='Radio' OR "FIELD_TYPE"='RadioHoriz' OR
"FIELD_TYPE"='RadioPara' OR "FIELD_TYPE"='Select' OR "FIELD_TYPE"='SelectM') AND "FIELD_NAME"=:B2 AND
"A"."ACCOUNT_ID"="$nso_col_1" AND "A"."JOB_ID"="JOB_ID" AND "A"."APPLICATION_ID"=:B3 AND
DECODE("A"."TRAY",'Incomplete','Incomplete','Complete')='Complete' AND "A"."DELETED"=0))
PLAN_TABLE_OUTPUT
5 - filter("FIELD_NAME"="AF"."FIELD_NAME" AND "INSTANCE"="AF"."FIELD_INSTANCE")
7 - access("AFO"."FIELD_NAME"="AF"."FIELD_NAME" AND "AFO"."FORM_ID"="AF"."FORM_ID")
8 - access("JF"."FORM_ID"="AF"."FORM_ID")
15 - filter("ACCOUNT_ID"=113346)
17 - access("ACCOUNT_ID"=113346)
22 - access("ACCOUNT_ID"=NULL)
23 - access("ACCOUNT_ID"=NULL)
24 - access("J"."ACCOUNT_ID"="$nso_col_1")
25 - access("JF"."JOB_ID"="$nso_col_1")
26 - filter("AF"."FIELD_TYPE"='Checkbox' OR "AF"."FIELD_TYPE"='Radio' OR "AF"."FIELD_TYPE"='RadioHoriz' OR
"AF"."FIELD_TYPE"='RadioPara' OR "AF"."FIELD_TYPE"='Select' OR "AF"."FIELD_TYPE"='SelectM')
PLAN_TABLE_OUTPUT FOR THE QUERY
28 - access("FIELD_VALUE"="AFO"."OPTION_TEXT")
29 - filter( EXISTS (SELECT 0 FROM "AGENCY_ACCOUNTS" "AGENCY_ACCOUNTS" WHERE "ACCOUNT_ID"=NULL AND
("ACCOUNT_ID"=:B1)))
33 - filter(DECODE("A"."TRAY",'Incomplete','Incomplete','Complete')='Complete' AND "A"."DELETED"=0)
34 - access("A"."APPLICATION_ID"=:B1)
36 - access("A"."JOB_ID"="JOB_ID")
37 - filter("A"."ACCOUNT_ID"="$nso_col_1")
38 - filter("ACCOUNT_ID"=113346)
40 - access("ACCOUNT_ID"=113346)
45 - access("ACCOUNT_ID"=NULL)
46 - access("ACCOUNT_ID"=NULL)
PLAN_TABLE_OUTPUT
49 - access("FIELD_NAME"=:B1 AND ("FIELD_TYPE"='Checkbox' OR "FIELD_TYPE"='Radio' OR "FIELD_TYPE"='RadioHoriz'
OR "FIELD_TYPE"='RadioPara' OR "FIELD_TYPE"='Select' OR "FIELD_TYPE"='SelectM'))
50 - filter("ACCOUNT_ID"=:B1)
51 - filter("ACCOUNT_ID"=:B1)
53 - access("ACCOUNT_ID"=:B1)
58 - access("ACCOUNT_ID"=NULL)
59 - access("ACCOUNT_ID"=NULL)
106 rows selected.TKPROF FOR THE QUERY
call count cpu elapsed disk query current rows
Parse 1 0.05 0.08 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 17 1040.45 1018.36 0 48926569 0 229
total 19 1040.50 1018.44 0 48926569 0 229
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 68
Rows Row Source Operation
229 SORT GROUP BY (cr=48926569 pr=0 pw=0 time=1018362160 us)
454 VIEW (cr=48926569 pr=0 pw=0 time=1018361382 us)
454 HASH GROUP BY (cr=48926569 pr=0 pw=0 time=1018360468 us)
185302 FILTER (cr=48926569 pr=0 pw=0 time=877249113 us)
1440799 TABLE ACCESS BY INDEX ROWID APPLICATION_DATA (cr=11309333 pr=0 pw=0 time=213262026 us)
82907114 NESTED LOOPS (cr=174051 pr=0 pw=0 time=166906535 us)
1790 HASH JOIN (cr=625 pr=0 pw=0 time=41617 us)
121 HASH JOIN (cr=310 pr=0 pw=0 time=11263 us)
39 NESTED LOOPS (cr=121 pr=0 pw=0 time=6894 us)
44 VIEW VW_NSO_3 (cr=75 pr=0 pw=0 time=6424 us)
44 HASH UNIQUE (cr=75 pr=0 pw=0 time=6333 us)
44 TABLE ACCESS BY INDEX ROWID JOBS (cr=75 pr=0 pw=0 time=3090 us)
52 NESTED LOOPS (cr=32 pr=0 pw=0 time=58177 us)
7 VIEW VW_NSO_1 (cr=23 pr=0 pw=0 time=1242 us)
7 CONNECT BY WITH FILTERING (cr=23 pr=0 pw=0 time=1212 us)
1 TABLE ACCESS BY INDEX ROWID AGENCY_ACCOUNTS (cr=3 pr=0 pw=0 time=185 us)
1 INDEX UNIQUE SCAN AGENCY_ACCOUNTS_ACCOUNT_ID (cr=2 pr=0 pw=0 time=100 us)(object id 60086)
6 NESTED LOOPS (cr=20 pr=0 pw=0 time=590 us)
7 BUFFER SORT (cr=0 pr=0 pw=0 time=248 us)
7 CONNECT BY PUMP (cr=0 pr=0 pw=0 time=95 us)
6 TABLE ACCESS BY INDEX ROWID AGENCY_ACCOUNTS (cr=20 pr=0 pw=0 time=314 us)
6 INDEX UNIQUE SCAN AGENCY_ACCOUNTS_ACCOUNT_ID (cr=14 pr=0 pw=0 time=188 us)(object id 60086)
0 TABLE ACCESS FULL AGENCY_ACCOUNTS (cr=0 pr=0 pw=0 time=0 us)
44 INDEX RANGE SCAN JOBS_ACCOUNT_ID (cr=9 pr=0 pw=0 time=280 us)(object id 60253)
39 INDEX RANGE SCAN JOBS_FORMS_JID_FID (cr=46 pr=0 pw=0 time=968 us)(object id 60299)
3579 TABLE ACCESS FULL APPLICATION_FIELDS (cr=189 pr=0 pw=0 time=14469 us)
32524 TABLE ACCESS FULL APPLICATION_FIELD_OPTIONS (cr=315 pr=0 pw=0 time=32629 us)
82905323 INDEX RANGE SCAN IDX$$_B8D40001 (cr=173426 pr=0 pw=0 time=83870105 us)(object id 60121)
185297 FILTER (cr=37617236 pr=0 pw=0 time=749052070 us)
185297 MERGE JOIN CARTESIAN (cr=37617196 pr=0 pw=0 time=742583363 us)
185297 NESTED LOOPS (cr=35393366 pr=0 pw=0 time=706772617 us)
1139675 NESTED LOOPS (cr=9180841 pr=0 pw=0 time=84949686 us)
1140164 TABLE ACCESS BY INDEX ROWID APPLICATIONS (cr=5760834 pr=0 pw=0 time=46774108 us)
1440060 INDEX UNIQUE SCAN APPS_APP_ID (cr=4320774 pr=0 pw=0 time=24380604 us)(object id 60107)
1139675 TABLE ACCESS BY INDEX ROWID JOBS (cr=3420007 pr=0 pw=0 time=28126171 us)
1139675 INDEX UNIQUE SCAN JOBS_JOB_ID (cr=2280328 pr=0 pw=0 time=14563524 us)(object id 60252)
185297 VIEW VW_NSO_2 (cr=26212525 pr=0 pw=0 time=613602445 us)
6866175 CONNECT BY WITH FILTERING (cr=26212525 pr=0 pw=0 time=614183170 us)
1139675 TABLE ACCESS BY INDEX ROWID AGENCY_ACCOUNTS (cr=3419025 pr=0 pw=0 time=24323520 us)
1139675 INDEX UNIQUE SCAN AGENCY_ACCOUNTS_ACCOUNT_ID (cr=2279350 pr=0 pw=0 time=13905212 us)(object id 60086)
6838050 NESTED LOOPS (cr=22793500 pr=0 pw=0 time=388173853 us)
7977725 BUFFER SORT (cr=0 pr=0 pw=0 time=178812411 us)
7977725 CONNECT BY PUMP (cr=0 pr=0 pw=0 time=57522094 us)
6838050 TABLE ACCESS BY INDEX ROWID AGENCY_ACCOUNTS (cr=22793500 pr=0 pw=0 time=179425469 us)
6838050 INDEX UNIQUE SCAN AGENCY_ACCOUNTS_ACCOUNT_ID (cr=15955450 pr=0 pw=0 time=113988543 us)(object id 60086)
0 TABLE ACCESS FULL AGENCY_ACCOUNTS (cr=0 pr=0 pw=0 time=0 us)
185297 BUFFER SORT (cr=2223830 pr=0 pw=0 time=24721936 us)
1208625 INLIST ITERATOR (cr=2223830 pr=0 pw=0 time=26470412 us)
1208625 INDEX RANGE SCAN IDX$$_91CA0001 (cr=2223830 pr=0 pw=0 time=18174073 us)(object id 60129)
2 FILTER (cr=40 pr=0 pw=0 time=1292 us)
2 CONNECT BY WITH FILTERING (cr=40 pr=0 pw=0 time=1276 us)
2 TABLE ACCESS BY INDEX ROWID AGENCY_ACCOUNTS (cr=6 pr=0 pw=0 time=86 us)
2 INDEX UNIQUE SCAN AGENCY_ACCOUNTS_ACCOUNT_ID (cr=4 pr=0 pw=0 time=46 us)(object id 60086)
10 NESTED LOOPS (cr=34 pr=0 pw=0 time=791 us)
12 BUFFER SORT (cr=0 pr=0 pw=0 time=369 us)
12 CONNECT BY PUMP (cr=0 pr=0 pw=0 time=127 us)
10 TABLE ACCESS BY INDEX ROWID AGENCY_ACCOUNTS (cr=34 pr=0 pw=0 time=376 us)
10 INDEX UNIQUE SCAN AGENCY_ACCOUNTS_ACCOUNT_ID (cr=24 pr=0 pw=0 time=242 us)(object id 60086)
0 TABLE ACCESS FULL AGENCY_ACCOUNTS (cr=0 pr=0 pw=0 time=0 us)Any help in tuning this query to run faster will be highly appreciated. I also noticed merge join certesian on the tkprof and explain plan. Any idea in takling that will also be appreciated.
Cheers,
AdeIt's quite hard to tune a query without seeing the table structure and available indices as well as relationship between each other but I'll try.
In your sql which you've given the table alias AD, you have this filter criteria
AND FIELD_NAME IN (
SELECT FIELD_NAME
FROM APPLICATION_FIELDS
WHERE FIELD_TYPE IN ('Checkbox','Radio','Select','SelectM', 'RadioHoriz','RadioPara')
) </br>
My question is, is FIELD_NAME a column in the APPLICATION_DATA table? If it is, try moving this clause outside of the current sub-query it is in, i.e. one more level up. It looks like you put them inside the wrong level.
I would also try converting this <COL> IN <SUB-QUERY> to a join, if that wouldn't affect the no. of rows returned. I can't tell for sure since I dont know the relationship between your tables.
It looks to me like you're doing this
SELECT <col list>
FROM ( SELECT -- LEVEL 1
FROM APPLICATION_DATA AD
WHERE AD.APPLICAITON_ID IN ( -- LEVEL 2
SELECT
FROM APPLICATIONS A
WHERE A.JOB_ID IN (
<SUBQUERY>
AND A.ACCOUNT_ID IN (
<SUBQUERY>
AND FIELDNAME IN ( -- SHOULD BE INSIDE LEVEL1
<SUBQUERY>
) AD,
( SELECT ....
) FD
WHERE .... -
How to use this sql query in oracle?
Hi all,
i am using one sql query that is
SELECT @ToDate = '2012-10-03 00:00:00.000'
select @BetweenDate = DATEADD(MM,-1,@ToDate)
select @FromDate = DATEADD(m,DATEDIFF(m,0,@BetweenDate),0)
SELECT @ToDate = DATEADD(month, ((YEAR(@BetweenDate) - 1900) * 12) + MONTH(@BetweenDate), -1)
so @todate value is = '2012-10-03 00:00:00.000'
so in @betweendate value will come 1 month before like '2012-09-03 00:00:00.000'
again in @fromdate value will come like that '2012-09-01 00:00:00.000' means first date of @betweendate
and again @todate value will come like that '2012-09-30 00:00:00.000' means last date of @betweendate
it's happening in sql and i have to use same logic in oracle also.
how to use it??
thanksdeclare
todate date:= to_date('2012-10-03 00:00:00','yyyy-mm-dd hh:mi:ss');
betwendate date := add_months(todate,-1);
for datediff / additions you can direct subtract/add two different date variables
like
datediff = betweendate -todate
dateadd := todate+1; -
Oracle 10g vs Oracle 11g query performance
Hi everyone,
We are moving from Oracle 10g to Oracle 11g database.
I have a query which in Oracle 1g takes 85 seconds to run, but when I run the same query in Oracle 11g database, it takes 635 seconds.
I have confirmed that all indexes on tables involved are enabled.
Does anyone have any pointers, what should I look into. I have compared explain plans and clearly they are different. Oracle 11g is taking a different approach than Oracle 1g.
ThanksPl post details of OS versions, exact database versions (to 4 digits) and init.ora parameters of the 10g and 11g databases. Have statistics been gathered after the upgrade ?
For posting tuning requests, pl see these threads
HOW TO: Post a SQL statement tuning request - template posting
When your query takes too long ...
Pl see if the SQL Performance Analyzer can help - MOS Doc 562899.1 (TESTING SQL PERFORMANCE IMPACT OF AN ORACLE 9i TO ORACLE DATABASE 10g RELEASE 2 UPGRADE WITH SQL PERFORMANCE ANALYZER)
HTH
Srini -
Oracle 11G - Update is very slow on View
I have big trouble with some Update query on Oracle 11G.
I have a set of tables (5) of identical structures and a view that consists in an UNION ALL of the 5 tables.
None of this table contains more than 20 000 rows.
Let's call the view V_INTE_NE. Each of the basic table has a PRIMARY KEY defined on 3 NUMBERS(10,0) -> INTE_REF / NE_REF / INSTANCE.
Now, I get 6 rows in another table and I want to update my view from the data of this small table (let's call it SMALL). This table has the 3 columns INTE_REF / NE_REF / INSTANCE.
When I try to join the two tables :
SELECT * FROM T_INTE_NE T2
WHERE EXISTS ( SELECT 1 FROM SMALL T1 WHERE T2.INTE_REF = T1.INTEREF AND T2.NE_REF = T1.NEREF AND T2.INTE_INST = T1.INSTANCE )
I get the 6 lines in 0.037 seconds
When I try to update the view (I have an INSTEAD OF trigger that does nothing (just return for testing even without modifying anything), I execute the following query :
UPDATE T_INTE_NE T2
SET INTE_STATE = -11 WHERE
EXISTS ( SELECT 1 FROM SMALL T1 WHERE T2.INTE_REF = T1.INTEREF AND T2.NE_REF = T1.NEREF AND T2.INTE_INST = T1.INSTANCE )
The 6 rows are updated (at least TRIGGER is called) in 20 seconds.
However, in the execution plan, I can't see where Oracle takes time to achieve the query :
Plan hash value: 907176690
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | UPDATE STATEMENT | | 6 | 36870 | 153 (1)| 00:00:02 |
| 1 | UPDATE | T_INTE_NE | | | | |
|* 2 | HASH JOIN RIGHT SEMI | | 6 | 36870 | 153 (1)| 00:00:02 |
| 3 | TABLE ACCESS FULL | SMALL | 6 | 234 | 9 (0)| 00:00:01 |
| 4 | VIEW | T_INTE_NE | 6 | 36636 | 143 (0)| 00:00:02 |
| 5 | VIEW | X_V_T_INTE_NE | 6 | 18636 | 143 (0)| 00:00:02 |
| 6 | UNION-ALL | | | | | |
| 7 | TABLE ACCESS FULL| SECNODE1_T_INTE_NE | 1 | 3106 | 60 (0)| 00:00:01 |
| 8 | TABLE ACCESS FULL| SECNODE2_T_INTE_NE | 1 | 3106 | 60 (0)| 00:00:01 |
| 9 | TABLE ACCESS FULL| SECNODE3_T_INTE_NE | 1 | 3106 | 2 (0)| 00:00:01 |
| 10 | TABLE ACCESS FULL| SECNODE4_T_INTE_NE | 1 | 3106 | 2 (0)| 00:00:01 |
| 11 | TABLE ACCESS FULL| SECNODE5_T_INTE_NE | 1 | 3106 | 2 (0)| 00:00:01 |
| 12 | TABLE ACCESS FULL| SYS_T_INTE_NE | 1 | 3106 | 17 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("T2"."INTE_REF"="T1"."INTEREF" AND "T2"."NE_REF"="T1"."NEREF" AND
"T2"."INTE_INST"="T1"."INSTANCE")
Note
- dynamic sampling used for this statement (level=2)
Statistics
3 user calls
0 physical read total bytes
0 physical write total bytes
0 spare statistic 3
0 commit cleanout failures: cannot pin
0 TBS Extension: bytes extended
0 total number of times SMON posted
0 SMON posted for undo segment recovery
0 SMON posted for dropping temp segment
0 segment prealloc tasks
What could explain the difference ?
I get exactly the same execution plan (when autotrace is ON).
Furthermore, if I try to do the same update on each of the basic tables, I get the rows updated instantaneously.
Is there any reason for avoiding this kind of query ?
Any help would be greatly appreciated :-)
Regards,
PatrickSorry for this, I lost myself in conjonctures and I didn't think I would have to explain the whole case.
So, I wrote a small piece of PL/SQL that reproduces the same issue.
It seems that my issue is not due to the UPDATE but to the use of the IN predicate.
As you can see at the end of the script, I try to join the 2 tables using different technics.
The first query is very fast, the second is very slow.
I need the second one if I want to do any update.
DROP TABLE Part1;
DROP TABLE Part2;
DROP TABLE Part3;
DROP TABLE Part4;
CREATE TABLE Part1 ( Key1 NUMBER(10, 0), Key2 NUMBER(10, 0), Key3 NUMBER(10, 0), PartId NUMBER(10, 0) DEFAULT( 1 ) NOT NULL, Data1 VARCHAR2(1000), X_Data2 VARCHAR2(2000) NULL, X_Data3 VARCHAR2(2000) NULL, CONSTRAINT PK_Part1 PRIMARY KEY( Key1, Key2, Key3 ) );
CREATE TABLE Part2 ( Key1 NUMBER(10, 0), Key2 NUMBER(10, 0), Key3 NUMBER(10, 0), PartId NUMBER(10, 0) DEFAULT( 2 ) NOT NULL, Data1 VARCHAR2(1000), X_Data2 VARCHAR2(2000) NULL, X_Data3 VARCHAR2(2000) NULL, CONSTRAINT PK_Part2 PRIMARY KEY( Key1, Key2, Key3 ) );
CREATE TABLE Part3 ( Key1 NUMBER(10, 0), Key2 NUMBER(10, 0), Key3 NUMBER(10, 0), PartId NUMBER(10, 0) DEFAULT( 3 ) NOT NULL, Data1 VARCHAR2(1000), X_Data2 VARCHAR2(2000) NULL, X_Data3 VARCHAR2(2000) NULL, CONSTRAINT PK_Part3 PRIMARY KEY( Key1, Key2, Key3 ) );
CREATE TABLE Part4 ( Key1 NUMBER(10, 0), Key2 NUMBER(10, 0), Key3 NUMBER(10, 0), PartId NUMBER(10, 0) DEFAULT( 4 ) NOT NULL, Data1 VARCHAR2(1000), X_Data2 VARCHAR2(2000) NULL, X_Data3 VARCHAR2(2000) NULL, CONSTRAINT PK_Part4 PRIMARY KEY( Key1, Key2, Key3 ) );
CREATE OR REPLACE FUNCTION Decrypt
x_in IN VARCHAR2
) RETURN VARCHAR2
AS
x_out VARCHAR2(2000);
BEGIN
SELECT REVERSE( x_in ) INTO x_out FROM DUAL;
RETURN ( x_out );
END;
CREATE OR REPLACE VIEW AllParts AS
SELECT Key1, Key2, Key3, PartId, Data1, Decrypt( X_Data2 ) AS Data2, Decrypt( X_Data3 ) AS Data3 FROM Part1
UNION ALL
SELECT Key1, Key2, Key3, PartId, Data1, Decrypt( X_Data2 ) AS Data2, Decrypt( X_Data3 ) AS Data3 FROM Part2
UNION ALL
SELECT Key1, Key2, Key3, PartId, Data1, Decrypt( X_Data2 ) AS Data2, Decrypt( X_Data3 ) AS Data3 FROM Part3
UNION ALL
SELECT Key1, Key2, Key3, PartId, Data1, Decrypt( X_Data2 ) AS Data2, Decrypt( X_Data3 ) AS Data3 FROM Part4;
DROP TABLE Small;
CREATE TABLE Small ( Key1 NUMBER(10, 0), Key2 NUMBER(10, 0), Key3 NUMBER(10, 0), Data1 VARCHAR2(1000) );
BEGIN
DECLARE
n_Key NUMBER(10, 0 ) := 0;
BEGIN
WHILE ( n_Key < 50000 )
LOOP
INSERT INTO Part1( Key1, Key2, Key3 )
VALUES( n_Key, FLOOR( n_Key / 10 ), FLOOR( n_Key / 100 ) );
INSERT INTO Part2( Key1, Key2, Key3 )
VALUES( n_Key, FLOOR( n_Key / 10 ), FLOOR( n_Key / 100 ) );
INSERT INTO Part3( Key1, Key2, Key3 )
VALUES( n_Key, FLOOR( n_Key / 10 ), FLOOR( n_Key / 100 ) );
INSERT INTO Part4( Key1, Key2, Key3 )
VALUES( n_Key, FLOOR( n_Key / 10 ), FLOOR( n_Key / 100 ) );
n_Key := n_Key + 1;
END LOOP;
INSERT INTO Small( Key1, Key2, Key3, Data1 ) VALUES ( 1000, 100, 10, 'Test 1000' );
INSERT INTO Small( Key1, Key2, Key3, Data1 ) VALUES ( 3000, 300, 30, 'Test 3000' );
INSERT INTO Small( Key1, Key2, Key3, Data1 ) VALUES ( 5000, 500, 50, 'Test 5000' );
COMMIT;
END;
END;
SELECT T2.*
FROM Small T1, AllParts T2
WHERE T2.Key1 = T1.Key1 AND T2.Key2 = T1.Key2 AND T2.Key3 = T1.Key3;
SELECT T1.*
FROM AllParts T1
WHERE ( T1.Key1, T1.Key2, T1.Key3 ) IN ( SELECT T2.Key1, T2.Key2, T2.Key3 FROM Small T2 ); -
Oracle 11g bug for column ambigously defined error
I have below format query running on Oracle 10g without any issues
select col1
from (select col1
from (select 'A' col1
from dual)
) v1
inner join (select col1 as col2
from (select 'A' col1
from dual)
) v2
on (v1.col1=v2.col2);
When I run the exact same query on Oracle 11g I get column ambiguously defined error. But when I change the query to as below it works fine on 11g
select v1.col1
from (select col1
from (select 'A' col1
from dual)
) v1
inner join (select col1 as col2
from (select 'A' col1
from dual)
) v2
on (v1.col1=v2.col2);
Is it because 11g ignores column alias in my inner queries.I'd tend to agree that this seems to be a bug in 11.1.0.7 (at least, that's the version I'm running it in)
It's not even that Oracle doesn't know about the column aliases, you can remove the aliases in the ON without a problem, i.e.
SELECT v1.col1
FROM
(SELECT col1 FROM
(SELECT 'A' col1 FROM dual
) v1
INNER JOIN
(SELECT col1 AS col2 FROM
(SELECT 'A' col1 FROM dual
) v2
ON (col1=col2);works fine. Using the old join syntax also seems to work fine
SELECT col1
FROM
(SELECT col1 FROM
(SELECT 'A' col1 FROM dual
) v1,
(SELECT col1 AS col2 FROM
(SELECT 'A' col1 FROM dual
) v2
WHERE (col1=col2);So it appears that something in the SQL 99 parser is broken. Have you logged a bug in Metalink?
Justin -
SQL performance slow -- oracle 10g to oracle 11g
Hi,
We are have two development server, here we can call server10 and server11.
Server’s having same hardware and OS, but different oracle version, server 10 and server 11 having oracle 10g and oracle 11g respectively.
Problem, when you run sql query in oracle 11g it’s very slow compare to oracle 10g server.
Here I have checked
1) sga size – comparatively 11g size is big
2) no full table scan
OS – SUN
DB: 11.1.0.7.0, 10.2.0.4.0mmee wrote:
Hi,
We are have two development server, here we can call server10 and server11.
Server’s having same hardware and OS, but different oracle version, server 10 and server 11 having oracle 10g and oracle 11g respectively.
Problem, when you run sql query in oracle 11g it’s very slow compare to oracle 10g server.
Here I have checked
1) sga size – comparatively 11g size is big
2) no full table scan
OS – SUN
DB: 11.1.0.7.0, 10.2.0.4.0If the query is running slow, the sga size should not be the first thing to check. PLease post the execution plans of the queries from both the servers. Please try to post the tkprof output of the trace of both. The reason for this that explain plan may lie to us about what has happened but trace would be the real picture only.
HTH
Aman....
PS: Don't forget to use the code tag and using the Preview tab to see how the code looks. A better formatted post would most likely get better attention and response. -
Please help me to tune this PL/SQL...
Hi everyone,
I have a SQL query which runs ok when i run it individually but the same query if
i use it in a procedure.The procedure is hanging up.Could someone please help to tune this
SQL query and please check my procedure why is it hanging up.
SQL Query
=========
SELECT active_members.member_nbr,
active_members.name_last,
active_members.name_first,
active_members.name_middle,
active_members.dob,
active_members.sex,
active_members.subsciber_nbr,
active_members.ssn,
active_members.name_suffix,
active_members.class_x,
active_members.aff_nbr,
CASE
WHEN TRIM(active_members.class_x) = 'SE' THEN
(SELECT DISTINCT(mssp.member_nbr)
FROM member_span mssp
WHERE SUBSTR(mssp.member_nbr, 1, 9) = SUBSTR(active_members.member_nbr, 1, 9)
AND mssp.class_x = 'SP'
AND rownum = 1)
WHEN TRIM(active_members.class_x) = 'SP' THEN
(SELECT DISTINCT(mssp.member_nbr)
FROM member_span mssp
WHERE SUBSTR(mssp.member_nbr, 1, 9) = SUBSTR(active_members.member_nbr, 1, 9)
AND mssp.class_x = 'SE'
AND rownum = 1)
ELSE
NULL
END)
spouse_member_nbr,
active_members.division_nbr,
active_members.ymdeff,
active_members.ymdend,
active_members.actual_ymd_enddt,
active_members.email_id,
active_members.network_id,
active_members.insurance_company_code,
active_members.cob_flag,
active_members.vip_flag,
active_members.pre_x_flag,
active_members.region,
active_contracts.language_x,
active_contracts.corp_nbr,
active_members.group_nbr,
active_members.non_erisa_status
FROM
(SELECT mb_active.member_nbr,
mb_active.contract_nbr,
mb_active.name_last,
mb_active.name_first,
mb_active.name_middle,
ms_active.ymdeff,
ms_active.ymdend,
to_char(to_date(
CASE
WHEN LENGTH(mb_active.ymdbirth) = 8 THEN mb_active.ymdbirth
ELSE NULL
END, 'YYYYMMDD'), 'MM/DD/YYYY') dob,
mb_active.sex,
to_char(to_date(ms_active.ymdeff, 'YYYYMMDD'), 'MM/DD/YYYY') ymdeff_formatted,
to_char(to_date(ms_active.ymdend, 'YYYYMMDD'), 'MM/DD/YYYY') ymdend_formatted,
ms_active.void,
CASE
WHEN SUBSTR(mb_active.member_nbr, 10, 2) = '00' THEN mb_active.member_nbr
ELSE SUBSTR(mb_active.member_nbr, 1, 9) || '00'
END) subsciber_nbr,
mb_active.ssn,
mb_active.name_suffix,
ms_active.class_x,
ms_active.aff_nbr,
ms_active.division_nbr,
CASE
WHEN TRIM(ms_active.ymdend) = '99991231' THEN NULL
ELSE to_char(to_date(ms_active.ymdend, 'YYYYMMDD'), 'MM/DD/YYYY')
END) actual_ymd_enddt,
CASE
WHEN TRIM(ms_active.business_unit) = '01' THEN ms_active.business_unit || '-' || ms_active.prog_nbr
WHEN TRIM(ms_active.business_unit) = '03' THEN ms_active.business_unit || '-' || ms_active.prog_nbr || '-' || ms_active.carrier
ELSE NULL
END) network_id,
ms_active.business_unit || '-' || ms_active.prog_nbr || '-' || ms_active.carrier insurance_company_code,
(SELECT DISTINCT(email)
FROM dbo.av_mem_email
WHERE dbo.av_mem_email.member_nbr = mb_active.member_nbr
AND rownum = 1)
email_id,
mb_active.lr_response cob_flag,
mb_active.record_nbr vip_flag,
ms_active.pre_exist pre_x_flag,
ms_active.region region,
ms_active.group_nbr,
CASE
WHEN
(SELECT TRIM(div.div_status)
FROM division div
WHERE TRIM(div.division_nbr) = TRIM(ms_active.division_nbr)) = 'NULL' THEN
'Y'
ELSE
'N'
END)
non_erisa_status
FROM member mb_active,
member_span ms_active
WHERE mb_active.member_nbr = ms_active.member_nbr
AND(20090707 BETWEEN ms_active.ymdeff
AND ms_active.ymdend
AND TRIM(ms_active.void) IS NULL
active_members,
(SELECT DISTINCT(contract.contract_nbr),
contract.language_x,
contract_span.corp_nbr
FROM contract,
contract_span
WHERE contract.contract_nbr = contract_span.contract_nbr
AND(20090707 BETWEEN contract_span.ymdeff
AND contract_span.ymdend)
AND TRIM(contract_span.void) IS
NULL)
active_contracts
WHERE TRIM(active_members.contract_nbr) = TRIM(active_contracts.contract_nbr);
Taking around 6 minute to run and it returns """"268267"""" records
Explain Plan for the above SQL:
===============================
"PLAN_TABLE_OUTPUT"
"Plan hash value: 379550299"
"| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |"
"| 0 | SELECT STATEMENT | | 2609K| 659M| | 91679 (3)| 00:18:21 |"
"| 1 | HASH UNIQUE | | 1 | 16 | | 54461 (2)| 00:10:54 |"
"|* 2 | COUNT STOPKEY | | | | | | |"
"|* 3 | TABLE ACCESS FULL | MEMBER_SPAN | 12891 | 201K| | 54459 (2)| 00:10:54 |"
"| 4 | HASH UNIQUE | | 1 | 16 | 2424K| 54736 (2)| 00:10:57 |"
"|* 5 | COUNT STOPKEY | | | | | | |"
"|* 6 | TABLE ACCESS FULL | MEMBER_SPAN | 51541 | 805K| | 54459 (2)| 00:10:54 |"
"| 7 | HASH UNIQUE | | 1 | 50 | | 64 (4)| 00:00:01 |"
"|* 8 | COUNT STOPKEY | | | | | | |"
"|* 9 | TABLE ACCESS FULL | AV_MEM_EMAIL | 1 | 50 | | 63 (2)| 00:00:01 |"
"|* 10 | TABLE ACCESS FULL | DIVISION | 1 | 14 | | 3 (0)| 00:00:01 |"
"|* 11 | HASH JOIN | | 2609K| 659M| | 91679 (3)| 00:18:21 |"
"| 12 | VIEW | | 581 | 12782 | | 8184 (4)| 00:01:39 |"
"| 13 | HASH UNIQUE | | 581 | 26145 | | 8184 (4)| 00:01:39 |"
"| 14 | TABLE ACCESS BY INDEX ROWID| CONTRACT | 1 | 14 | | 2 (0)| 00:00:01 |"
"| 15 | NESTED LOOPS | | 581 | 26145 | | 8183 (4)| 00:01:39 |"
"|* 16 | TABLE ACCESS FULL | CONTRACT_SPAN | 581 | 18011 | | 7019 (5)| 00:01:25 |"
"|* 17 | INDEX RANGE SCAN | CONTRACT_IX1 | 1 | | | 1 (0)| 00:00:01 |"
"|* 18 | HASH JOIN | | 449K| 104M| 39M| 83466 (2)| 00:16:42 |"
"|* 19 | TABLE ACCESS FULL | MEMBER_SPAN | 449K| 34M| | 54964 (3)| 00:11:00 |"
"| 20 | TABLE ACCESS FULL | MEMBER | 1436K| 221M| | 14664 (2)| 00:02:56 |"
"Predicate Information (identified by operation id):"
" 2 - filter(ROWNUM=1)"
" 3 - filter(SUBSTR("MSSP"."MEMBER_NBR",1,9)=SUBSTR(:B1,1,9) AND "MSSP"."CLASS_X"='SP')"
" 5 - filter(ROWNUM=1)"
" 6 - filter(SUBSTR("MSSP"."MEMBER_NBR",1,9)=SUBSTR(:B1,1,9) AND "MSSP"."CLASS_X"='SE')"
" 8 - filter(ROWNUM=1)"
" 9 - filter("AV_MEM_EMAIL"."MEMBER_NBR"=:B1)"
" 10 - filter(TRIM("DIV"."DIVISION_NBR")=TRIM(:B1))"
" 11 - access(TRIM("MB_ACTIVE"."CONTRACT_NBR")=TRIM("ACTIVE_CONTRACTS"."CONTRACT_NBR"))"
" 16 - filter("CONTRACT_SPAN"."YMDEFF"<=20090707 AND TRIM("CONTRACT_SPAN"."VOID") IS NULL AND "
" "CONTRACT_SPAN"."YMDEND">=20090707)"
" 17 - access("CONTRACT"."CONTRACT_NBR"="CONTRACT_SPAN"."CONTRACT_NBR")"
" 18 - access("MB_ACTIVE"."MEMBER_NBR"="MS_ACTIVE"."MEMBER_NBR")"
" 19 - filter(TRIM("MS_ACTIVE"."VOID") IS NULL AND "MS_ACTIVE"."YMDEFF"<=20090707 AND "
" "MS_ACTIVE"."YMDEND">=20090707)"
SAME SQL IN A PROCEDURE..IT IS HANGING UP
========================================
create or replace PROCEDURE TEST_CURRENT_PCP_SPAN is
EXTRACTED_STRING VARCHAR2(32767);
FILEHANDLER UTL_FILE.FILE_TYPE;
test_str varchar2(100);
pcp_eff_date number(10);
file_name varchar2(50);
CURSOR MEMBERS
IS
SELECT active_members.member_nbr,
active_members.name_last,
active_members.name_first,
active_members.name_middle,
active_members.dob,
active_members.sex,
active_members.subsciber_nbr,
active_members.ssn,
active_members.name_suffix,
active_members.class_x,
active_members.aff_nbr,
CASE
WHEN TRIM(active_members.class_x) = 'SE' THEN
(SELECT DISTINCT(mssp.member_nbr)
FROM member_span mssp
WHERE SUBSTR(mssp.member_nbr, 1, 9) = SUBSTR(active_members.member_nbr, 1, 9)
AND mssp.class_x = 'SP'
AND rownum = 1)
WHEN TRIM(active_members.class_x) = 'SP' THEN
(SELECT DISTINCT(mssp.member_nbr)
FROM member_span mssp
WHERE SUBSTR(mssp.member_nbr, 1, 9) = SUBSTR(active_members.member_nbr, 1, 9)
AND mssp.class_x = 'SE'
AND rownum = 1)
ELSE
NULL
END)
spouse_member_nbr,
active_members.division_nbr,
active_members.ymdeff,
active_members.ymdend,
active_members.actual_ymd_enddt,
active_members.email_id,
active_members.network_id,
active_members.insurance_company_code,
active_members.cob_flag,
active_members.vip_flag,
active_members.pre_x_flag,
active_members.region,
active_contracts.language_x,
active_contracts.corp_nbr,
active_members.group_nbr,
active_members.non_erisa_status
FROM
(SELECT mb_active.member_nbr,
mb_active.contract_nbr,
mb_active.name_last,
mb_active.name_first,
mb_active.name_middle,
ms_active.ymdeff,
ms_active.ymdend,
to_char(to_date(
CASE
WHEN LENGTH(mb_active.ymdbirth) = 8 THEN mb_active.ymdbirth
ELSE NULL
END, 'YYYYMMDD'), 'MM/DD/YYYY') dob,
mb_active.sex,
to_char(to_date(ms_active.ymdeff, 'YYYYMMDD'), 'MM/DD/YYYY') ymdeff_formatted,
to_char(to_date(ms_active.ymdend, 'YYYYMMDD'), 'MM/DD/YYYY') ymdend_formatted,
ms_active.void,
CASE
WHEN SUBSTR(mb_active.member_nbr, 10, 2) = '00' THEN mb_active.member_nbr
ELSE SUBSTR(mb_active.member_nbr, 1, 9) || '00'
END) subsciber_nbr,
mb_active.ssn,
mb_active.name_suffix,
ms_active.class_x,
ms_active.aff_nbr,
ms_active.division_nbr,
CASE
WHEN TRIM(ms_active.ymdend) = '99991231' THEN NULL
ELSE to_char(to_date(ms_active.ymdend, 'YYYYMMDD'), 'MM/DD/YYYY')
END) actual_ymd_enddt,
CASE
WHEN TRIM(ms_active.business_unit) = '01' THEN ms_active.business_unit || '-' || ms_active.prog_nbr
WHEN TRIM(ms_active.business_unit) = '03' THEN ms_active.business_unit || '-' || ms_active.prog_nbr || '-' || ms_active.carrier
ELSE NULL
END) network_id,
ms_active.business_unit || '-' || ms_active.prog_nbr || '-' || ms_active.carrier insurance_company_code,
(SELECT DISTINCT(email)
FROM dbo.av_mem_email
WHERE dbo.av_mem_email.member_nbr = mb_active.member_nbr
AND rownum = 1)
email_id,
mb_active.lr_response cob_flag,
mb_active.record_nbr vip_flag,
ms_active.pre_exist pre_x_flag,
ms_active.region region,
ms_active.group_nbr,
CASE
WHEN
(SELECT TRIM(div.div_status)
FROM division div
WHERE TRIM(div.division_nbr) = TRIM(ms_active.division_nbr)) = 'NULL' THEN
'Y'
ELSE
'N'
END)
non_erisa_status
FROM member mb_active,
member_span ms_active
WHERE mb_active.member_nbr = ms_active.member_nbr
AND(20090707 BETWEEN ms_active.ymdeff
AND ms_active.ymdend
AND TRIM(ms_active.void) IS NULL
active_members,
(SELECT DISTINCT(contract.contract_nbr),
contract.language_x,
contract_span.corp_nbr
FROM contract,
contract_span
WHERE contract.contract_nbr = contract_span.contract_nbr
AND(20090707 BETWEEN contract_span.ymdeff
AND contract_span.ymdend)
AND TRIM(contract_span.void) IS
NULL)
active_contracts
WHERE TRIM(active_members.contract_nbr) = TRIM(active_contracts.contract_nbr);
TYPE MEM IS TABLE OF MEMBERS%ROWTYPE INDEX BY PLS_INTEGER;
TABLE_MEM MEM;
MEMBER_ADDR MGONZALEZ.CPKG_UTIL.ADDR;
BEGIN
test_str := '''A10000213'''||','||'''A10000213''';
insert into test_number_char(str) values ('start time of MEMBER_LOAD_CURRENT_PCP_SPAN '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
file_name := 'member_load'||to_char(sysdate,'YYYYMMDDHH24MI')||'.txt';
FILEHANDLER := UTL_FILE.FOPEN('AVMED_UTL_FILE',file_name, 'W',10000);
insert into test_number_char(str) values ('start time of opening members cursor(before open members command) '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
OPEN MEMBERS;
LOOP
FETCH MEMBERS
BULK COLLECT INTO TABLE_MEM LIMIT 1000 ;
EXIT WHEN TABLE_MEM.COUNT = 0;
insert into test_number_char(str) values ('start time of outer loop '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
FOR i IN 1 .. TABLE_MEM.COUNT
LOOP
EXTRACTED_STRING := TRIM(TABLE_MEM(i).MEMBER_NBR)||'| '||
TRIM(TABLE_MEM(i).NAME_LAST)||'| '||
TRIM(TABLE_MEM(i).NAME_FIRST)||'| '||
TRIM(TABLE_MEM(i).NAME_MIDDLE)||'| '||
TRIM(TABLE_MEM(i).ssn)||'| '||
TABLE_MEM(i).subsciber_nbr||'| '||
TRIM(TABLE_MEM(i).class_x)||'| '||
TRIM(TABLE_MEM(i).DOB)||'| '||
TRIM(TABLE_MEM(i).SEX)||'| ' ;
EXTRACTED_STRING :=
EXTRACTED_STRING ||
TRIM(TABLE_MEM(i).aff_nbr)||'| '||
pcp_eff_date||'| '||
TABLE_MEM(i).actual_ymd_enddt||'| '||
TRIM(TABLE_MEM(i).division_nbr)||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
TABLE_MEM(i).network_id||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
TRIM(TABLE_MEM(i).name_suffix)||'| '||
' '||'| '||
TRIM(TABLE_MEM(i).spouse_member_nbr)||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
TRIM(TABLE_MEM(i).email_id)||'| '||
TABLE_MEM(i).Insurance_company_code||'| '||
TABLE_MEM(i).group_nbr||'| '||
TABLE_MEM(i).language_x||'| '||
TABLE_MEM(i).region||'| '||
TABLE_MEM(i).corp_nbr||'| '||
TABLE_MEM(i).non_erisa_status||'| '||
TABLE_MEM(i).cob_flag||'| '||
TABLE_MEM(i).pre_x_flag||'| '||
TABLE_MEM(i).vip_flag
EXTRACTED_STRING := rtrim(EXTRACTED_STRING,' ');
UTL_FILE.PUT_LINE(FILEHANDLER,EXTRACTED_STRING,TRUE);
EXTRACTED_STRING := NULL;
pcp_eff_date := NULL;
END LOOP;
insert into test_number_char(str) values ('end time of outer loop '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
END LOOP;
close members;
insert into test_number_char(str) values ('end time of opening members cursor '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
commit;
UTL_FILE.FCLOSE(FILEHANDLER);
insert into test_number_char(str) values ('End time of MEMBER_LOAD_CURRENT_PCP_SPAN '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line( 'ERROR getting members '
|| SQLCODE
|| ' '
|| SQLERRM);
END ;
In my Test table which i am inserting to check the times...
I am geting on these 2 records after that it hangs up...
start time of MEMBER_LOAD_CURRENT_PCP_SPAN 07/08/2009 11:41:21
start time of opening members cursor(before open members command) 07/08/2009 11:41:21I have to call some other functions for each member to get additional details thats the reason i am going for Procedure.Instead it is just a simple SQL
Thanks in advanceIt is taking lot of timeYou could perhaps split it up in smaller, isolated parts.
Running certain steps separate.
..is it possible to find out the issues without running the proc?Other than have other people on OTN give their ideas/share experiences?
Not that I'm aware of.
There are lots of statistical views, you might be able to deduct from their data, but I personally prefer running the procedure and just trace it. But I'm always willing to learn new approaches, btw.
Still, you have 2 things to look at, at least:
- avoid loops in loops if possible
- check your predicates, if you apply a function, you lose the index, unless you create a function based index.
edit
One more thing (how could I overlook that):
You commit your instrumentation code ( insert into test_number_char(str) ) IN the loop.
Please remove commit in your loops...
Commit only once, at the end of your transaction.
Never commit in a loop.
(Preferrably the client commits)
And remove every commit in your loop...
Edited by: hoek on Jul 8, 2009 8:03 PM
Maybe you are looking for
-
Font antialiasing in Word 2007 with Wine
Is there any way to get antialiasing in Word 2007 with Wine? Also I'm having some problems with bullets, they don't show up right. Maybe I'm missing a package for Wine or something? Thanks
-
Can't load drivers for KT4A-V with Sempron 2800
I have a kt4a-v board with Sempron 2800 chip 256mb geforce FX5500-TD256 TV DVI AGP card also 512 Mb PC2700 DDR Loading windows 98SE works fine until I try to load the drivers that come with the motherboard. Windows will then not load in anything othe
-
SQL elements int an array?
I want to get the names from each record in the following table and store them in an array according to their club. The database looks like this: PlayerID PlayerPosition PlayerFirstName PlayerLastName Club 1 GK S Taylor
-
Hi, I am new in iPhone development and I have a problem. In my viewDidLoad method I have: previewImage = [[UIImage alloc] initWithContentsOfFile:imagePath]]; self.imageView.image = self.previewImage; where previewImage is UIImage type. In View I have
-
Text scroller with 2 tabs ??
I have a text scroller that works just fine but client wants 2 tabs so when you tab over, different text displays for the same textbox. How do I code this? thanks