Help on tuning update query
Hi,
I work on below version of oracle.
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for IBM/AIX RISC System/6000: Version 10.2.0.5.0 - Productio
NLSRTL Version 10.2.0.5.0 - ProductionI have below the table structure and index created on the table. I have given the update and it's execution plan also. Can you please suggest a way to tune this query
Table has close to 50 million records in it.
Thanks much in advance for helping
SQL> CREATE TABLE TABLE1
2 (
3 COL1 CHAR(6 BYTE) NOT NULL,
4 COL2 NUMBER(13) NOT NULL,
5 COL3 CHAR(2 BYTE),
6 COL4 CHAR(3 BYTE),
7 COL5 CHAR(5 BYTE),
8 COL6 CHAR(7 BYTE),
9 COL7 NUMBER(4),
10 COL8 NUMBER(6),
11 COL9 NUMBER(9),
12 COL10 NUMBER(6),
13 COL11 CHAR(1 BYTE),
14 COL12 CHAR(2 BYTE)
15 )
16 TABLESPACE AGGREGNAT_DAT_2012T4
17 PCTUSED 0
18 PCTFREE 5
19 INITRANS 1
20 MAXTRANS 255
21 STORAGE (
22 INITIAL 80K
23 NEXT 1M
24 MINEXTENTS 1
25 MAXEXTENTS 2147483645
26 PCTINCREASE 0
27 BUFFER_POOL DEFAULT
28 )
29 NOLOGGING
30 COMPRESS
31 NOCACHE
32 NOPARALLEL
33 MONITORING;
Table created.
SQL> CREATE INDEX IND_TABLE1 ON TABLE1
2 (COL1, COL3, COL4, COL5, COL6,COL7)
3 NOLOGGING
4 TABLESPACE AGGREGNAT_IDX_2012T4
5 PCTFREE 5
6 INITRANS 2
7 MAXTRANS 255
8 STORAGE (
9 INITIAL 64K
10 NEXT 256K
11 MINEXTENTS 1
12 MAXEXTENTS 2147483645
13 PCTINCREASE 0
14 BUFFER_POOL DEFAULT
15 )
16 NOPARALLEL
17 COMPRESS 6;
Index created.
SQL> explain plan for UPDATE TABLE1 o1
2 SET o1.COL12 = 1
3 WHERE COL4 <> 'MDD'
4 AND EXISTS
5 ( SELECT 'E' FROM TABLE1 o2
6 WHERE o2.COL3 = o1.COL3 AND o2.COL4 = o1.COL4
7 AND o2.COL6 = o1.COL6 AND o2.COL7 = o1.COL7 AND o2.COL1 = o1.COL1
8 AND ( o2.COL9 < o1.COL9 OR ( o2.COL9 = o1.COL9 AND o2.rowid < o1.rowid))AND o2.COL5 = o1.COL5);
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 3057860847
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | UPDATE STATEMENT | | 9868K| 705M| 126M (1)|422:03:56 |
| 1 | UPDATE | TABLE1 | | | | |
|* 2 | FILTER | | | | | |
|* 3 | TABLE ACCESS FULL | TABLE1 | 25M| 1808M| 87011 (4)| 00:17:25 |
|* 4 | TABLE ACCESS BY INDEX ROWID| TABLE1 | 1 | 71 | 5 (0)| 00:00:01 |
|* 5 | INDEX RANGE SCAN | IND_TABLE1 | 1 | | 4 (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
2 - filter( EXISTS (SELECT 0 FROM "TABLE1" "O2" WHERE "O2"."COL7"=:B1 AND
"O2"."COL6"=:B2 AND "O2"."COL5"=:B3 AND "O2"."COL4"=:B4 AND "O2"."COL3"=:B5 AND
"O2"."COL1"=:B6 AND ("O2"."COL9"<:B7 OR "O2"."COL9"=:B8 AND "O2".ROWID<:B9)))
3 - filter("COL4"<>'MDD')
4 - filter("O2"."COL9"<:B1 OR "O2"."COL9"=:B2 AND "O2".ROWID<:B3)
5 - access("O2"."COL1"=:B1 AND "O2"."COL3"=:B2 AND "O2"."COL4"=:B3 AND
PLAN_TABLE_OUTPUT
"O2"."COL5"=:B4 AND "O2"."COL6"=:B5 AND "O2"."COL7"=:B6)
Note
- dynamic sampling used for this statement
27 rows selected.Thank you very much for guiding
Edited by: user12869307 on Feb 6, 2013 8:52 PM
Edited by: user12869307 on Feb 6, 2013 9:09 PM
Edited by: user12869307 on Feb 6, 2013 9:11 PM
Well,
it depends. The query is still a bit confusing to me.
You are trying to update rows having col4 different than 'MDD' if exists another row having same value for (COL1, COL3, COL4, COL5, COL6,COL7) and having a lower or equal value of col9.
What are the business requirements? Do you have some sample data and can explain the logic of this update?
This one:
( o2.COL9 < o1.COL9 OR ( o2.COL9 = o1.COL9 AND o2.rowid < o1.rowid))can actually be written in this way
(o2.COL9 <= o1.COL9 AND o2.rowid < o1.rowid)but why using o2.rowid < o1.rowid?
.>
You should not trust on rowid order.
Check what Tom Kyte is saying in Fetching last record from a table
the rowid is not "generated" in as much as "derived"
The rowid is the address of the row on disk.
Since space can and will be reused, rowids can and will be "reused"
A rowid implies NOTHING other than the location of the row physically. It does not imply age, order of insertion, or anything like that. Regards.
Al
Edited by: Alberto Faenza on Feb 6, 2013 5:10 PM
Similar Messages
-
Help with a update query from a subquery
Hello All,
I wanted to see if someone can help me with an update query.
I need to grab a latitude & longitude from a the same user that is in two accounts. therefore i am trying to update lat/long in a users table for one account based off of the same user in another account. I am matching the users up by phone number and last name. I tried a subquery but am having difficulty.
I was thinking of something like the following:
update users
set lat = getlat, long = getlong
inner join (select lat as getlat, long as get long from users where account_id = '1')
on phone = phone and last name = lastname
where account_id = '2' and lat IS NULL and long IS NULL
Am I going in the right direction???
Thanks in advance for any assistance!!!!What difficulty are you having? Have you tried what you posted and get an error?
Although someone may be able to give you sql advice here, I would try posting this over at Stack Overflow as its not really related to Coldfusion. -
I have two tables, one is sierra_price, which just has a part_number and a sierra_list
I have another table called products which is already populated with the parts from sierra_price, just no prices. It also has other products in it that are not included in sierra_price
What I need to do is update products with the base_price where products.sku is the same as sierra_price.part_number
I'm using db 10.2
I'm having trouble with this query...
UPDATE products
SET base_price = (select sierra_list from sierra_price where products.sku = sierra_price.part_number)
WHERE products.mfg_account_id = 4
I get the error:
ORA-01427: single-row subquery returns more than one row
Edited by: user10785816 on Jan 16, 2009 9:18 AMI got it to run with the query:
Update
(Select base_price bp, sierra_list sp from products p, sierra_price s where p.sku = s.part_number and p.mfg_account_id = 4)
SET bp = sp
I also had to set the primary key in sierra_price to the part_number to get it to work.
I'm quite new to SQL, but cheers for trying to help me! -
Hi,
I have a query updating a table having millon of rows.
update table_name set id=5This query is taking 35 minutes to execute every table my table is run for new data.
Is there any way to tune this query.
Thanksshavetachawla wrote:
Hi,
I have a query updating a table having millon of rows.
update table_name set id=5This query is taking 35 minutes to execute every table my table is run for new data.
Is there any way to tune this query.
ThanksAn index will probably not help this UPDATE because you are not using a WHERE clause to restrict rows.
The parallel query option might help - if you have the license. Also possible is parallel DML which is enabled apart from running the background select in parallel. You can read about parallel DML in the documentation.
Is this a one-time event? If so it might be easiest just to wait for it to finish. -
Hi,
I have the following query/report that takes hours to complete. Application version is 11.5.9 and database is on 9.2.0.6
{code}
SELECT c.inventory_location_id,
c.segment1
|| '.'
|| c.segment2
|| '.'
|| c.segment3
|| '.'
|| c.segment4 loc,
b.lot_number lot, -1 * b.primary_quantity lot_qty
FROM mtl_material_transactions a,
mtl_transaction_lot_numbers b,
mtl_item_locations c
WHERE a.transaction_id = b.transaction_id
AND a.locator_id = c.inventory_location_id
AND a.trx_source_line_id = :b1
ORDER BY 1
{code}
Explain Plan shows the following
{code}
SELECT STATEMENT CHOOSECost: 694
9 SORT ORDER BY Cost: 694 Bytes: 96 Cardinality: 2
8 TABLE ACCESS BY INDEX ROWID INV.MTL_TRANSACTION_LOT_NUMBERS Cost: 4 Bytes: 17 Cardinality: 1
7 NESTED LOOPS Cost: 693 Bytes: 96 Cardinality: 2
5 NESTED LOOPS Cost: 687 Bytes: 62 Cardinality: 2
2 TABLE ACCESS BY INDEX ROWID INV.MTL_MATERIAL_TRANSACTIONS Cost: 683 Bytes: 26 Cardinality: 2
1 INDEX FULL SCAN INV.NFPC_LOCATOR_ID_N1 Cost: 27 Cardinality: 2,579,440
4 TABLE ACCESS BY INDEX ROWID INV.MTL_ITEM_LOCATIONS Cost: 3 Bytes: 18 Cardinality: 1
3 INDEX RANGE SCAN INV.MTL_ITEM_LOCATIONS_U1 Cost: 2 Cardinality: 1
6 INDEX RANGE SCAN INV.MTL_TRANSACTION_LOT_NUMBERS_N1 Cost: 3 Cardinality: 1
{code}
Please let me know what other information I need to upload for any help.
Thanks
AJHi,
How many rows you have in MMT table?
Have you gathered the stats of the INV schema recently?
Did you test with some optimizer hints such as /*+ ordered */ or even /*+ rule */ ?
Regards,
Bashar -
Pls see this attached query. This is hitting a table which has around 110 mil recs. And this takes around 60 min to execute. IS there any way to tune it better? I am assuming that because this uses the ' With tmp as' clauses, it might be using the Indexes.
Can anyone suggest some tuning tips?
Satish
WITH all_edbc_pending_edg
AS (SELECT
a.day_sk,
a.case_num,
a.edg_num,
a.edg_trace_id,
a.application_dt,
a.current_elig_ind,
a.payment_begin_dt payment_beg_dt
FROM fct_eligibility_2 a,
dim_edg_activity_type b
WHERE a.current_elig_ind IN ('P','S','A')
and mod(case_num,2)=0
AND b.eff_end_dt IS NULL
AND b.activity_type_cd IN ('IN','RE','IR','PR','OG')
AND a.activity_type_sk=b.activity_type_sk
, Pick_Latest_Prior_Med as
SELECT t3.case_num,
t3.edg_num,
t3.current_elig_ind,
t3.application_dt,
t3.day_sk,
t3.payment_beg_dt,
t3.edg_trace_id
FROM (SELECT t2.*,
Row_number()
OVER(PARTITION BY t2.case_num,t2.edg_num, t2.application_dt ORDER BY t2.day_sk DESC, t2.payment_beg_dt DESC, t2.edg_trace_id DESC) AS rn
FROM all_edbc_pending_edg t2) t3
WHERE t3.rn = 1
Select
case_num,
edg_num,
application_dt,
payment_beg_dt,
edg_trace_id,
current_elig_ind
FROM
SELECT t1.case_num,
t1.edg_num,
t1.application_dt,
t1.payment_beg_dt,
t1.edg_trace_id,
t1.current_elig_ind
FROM (SELECT t.*,
Row_number()
OVER(PARTITION BY t.case_num,t.edg_num ORDER BY t.day_sk DESC, t.payment_beg_dt DESC, t.edg_trace_id DESC) AS rn
FROM Pick_Latest_Prior_Med t) t1
WHERE t1.rn = 1
) p
WHERE
current_elig_ind IN ('P','S')Check this link and post what is required as mentioned in the link.
SQL and PL/SQL FAQ
>
I am assuming that because this uses the ' With tmp as' clauses, it might be using the Indexes.
>
You don't need to assume. You can find out what's exactly happening if you follow the steps described in the above mentioned link.
Regards
Raj -
Hi,
I have a query in my proj where the same table is looked up twice in the same query.
Can anybody suggest in improving the performance of this query?
select * from table1 a1 where (a1.column1, a1.column2, a1.column3, a1.column4, a1.column5, a1.column6, a1.column7, a1.column8, a1.column9,
a1.column10) in ( select a2.column1, a2.column2, a2.column3, a2.column4, a2.column5, a2.column6, a2.column7, a2.column8, a2.column9,
a2.column10 from table1 a2 where column20 = '<condn>')
The table1 used here is same in outer query as well as the sub query. this is a example of what we use here, and the table1 contains 30 million rows. Though, creating index with 10 columns can be a option, we already have a unique index with 11 columns(which includes 10 from this query) and will that be helpful in anyway? or the same existing index can be forced?
Thanks a lot for ur timeDepending on the selectivity of column20 I am not sure Index is the best way to go. It might perform better with two full scans and a hash-join.
Anyway, I do prefer the syntax:
select /*+ leading(a2) */ a1.*
from table1 a1, table1 a2
where a2.column20 = '<condn>'
and a1.column1 = a2.column1
and a1.column2 = a2.column2
and a1.column3 = a2.column3
and a1.column4 = a2.column4
and a1.column5 = a2.column5
and a1.column6 = a2.column6
and a1.column7 = a2.column7
and a1.column8 = a2.column8
and a1.column9 = a2.column9
and a1.column10 = a2.column10;I've added a leading hint to tell oracle that the start table is a2. Might be useless.
Ensure your stats are up to date. You might need histograms here if your column20 is skewed.
Hope this helps,
François
Edited by: Francois Berger on Oct 24, 2008 1:47 AM -
This query only works if it return one row. But sometimes it returns more than one row, then I get error: "ORA-01427: single-row subquery returns more than one row"
How can I solve that? If it reurns more than one row, it should update all rows.
UPDATE TBLLEVPREC SET GOODSISSUEDATE_CHANGED = to_date('2007-02-14','YYYY-MM-DD'),
Rec_Date_Changed = SysDate,
Rec_Changed_by = 'TestUser'
Where IDT = ( Select IDT
from dd_tbllevprec
where dd_tbllevprec.days_late > 0
And dd_tbllevprec.exclude Is Null
And dd_tbllevprec.code_firstconfirmed Is Null
And dd_tbllevprec.salesorder = '1234567' )Hi,
You can do it two ways:
1:
UPDATE TBLLEVPREC SET GOODSISSUEDATE_CHANGED = to_date('2007-02-14','YYYY-MM-DD'),
Rec_Date_Changed = SysDate,
Rec_Changed_by = 'TestUser'
Where IDT = ( Select IDT
from dd_tbllevprec
where dd_tbllevprec.days_late > 0
And dd_tbllevprec.exclude Is Null
And dd_tbllevprec.code_firstconfirmed Is Null
And dd_tbllevprec.salesorder = '1234567' AND ROWNUM =1)
2:
UPDATE TBLLEVPREC a SET GOODSISSUEDATE_CHANGED = to_date('2007-02-14','YYYY-MM-DD'),
Rec_Date_Changed = SysDate,
Rec_Changed_by = 'TestUser'
Where EXISTS ( Select NULL
from dd_tbllevprec
where dd_tbllevprec.days_late > 0
And dd_tbllevprec.exclude Is Null
And dd_tbllevprec.code_firstconfirmed Is Null
And dd_tbllevprec.salesorder = '1234567'
AND a.IDT= dd_tbllevprec.IDT
Regards -
Hi all i have this query:
SELECT VTA.CO_VENDEDOR
,VTA.NB_VENDEDOR
,VTA.CO_CLASE_CLIENTE
,VTA.DE_CLASE_CLIENTE
,VTA.CO_CLIENTE
,VTA.NB_CLIENTE
,VTA.MN_VENDIDO
,NVL(DEV.MN_DEVUELTO,0) MN_DEVUELTO
,VTA.MN_VENDIDO - NVL(DEV.MN_DEVUELTO,0) MN_NETO_VENDIDO
,NVL(COB.MN_COBRADO,0) MN_COBRADO
,NVL(COB.MN_DESCUENTO,0) MN_DESCUENTO
,NVL(COB.MN_COBRADO,0) + NVL(COB.MN_DESCUENTO,0) MN_COBRADO_MAS_DESCUENTO
FROM (SELECT FCL.CTV_CO_CLASE_ORGANIZACION CO_CLASE_CLIENTE
,FCL.CTV_DE_CLASE_ORGANIZACION DE_CLASE_CLIENTE
,FCL.CO_ORGANIZACION CO_CLIENTE
,FCL.ORG_NB_CLIENTE NB_CLIENTE
,FCL.PER_CO_IDENTIFICACION_VENDEDOR CO_VENDEDOR
,FCL.PER_NB_PRIMER_NOMBRE_VENDEDOR||' '||
FCL.PER_NB_PRIMER_APELLIDO_VEND NB_VENDEDOR
,SUM((CA_PRODUCTO * (PR_PRODUCTO - NVL(PR_DESCUENTO_PRODUCTO,0))) * (1 - NVL(PC_DESCUENTO,0))) MN_VENDIDO
FROM S04_FACTURA_CLIENTE_TOTAL_R FCL
,S04_FACTURA_CLIENTE_PRD_TOT FPR
,(SELECT FCP.FAC_ID_FACTURA
,SUM(DDC.MN_DEBITO_CREDITO) /
SUM(FCP.CA_PRODUCTO * (FCP.PR_PRODUCTO - NVL(FCP.PR_DESCUENTO_PRODUCTO,0))) PC_DESCUENTO
FROM S04_DOCUMENTO_DEBITO_CREDITO_R DDC
,S04_FACTURA_CLIENTE_PRD_TOT FCP
WHERE DDC.ID_DOCUMENTO_REFERENCIA = FCP.FAC_ID_FACTURA
AND DDC.TDC_IN_DEBITO_CREDITO = 'C'
GROUP BY FCP.FAC_ID_FACTURA) DCT
WHERE FCL.ID_REGISTRO = FPR.FAC_ID_FACTURA
AND DCT.FAC_ID_FACTURA (+) = FPR.FAC_ID_FACTURA
AND FCL.FE_EMISION BETWEEN to_date('01112009','ddmmyyyy') AND to_date('29112009','ddmmyyyy')
AND FCL.ORG_ID_CLIENTE = NVL(NULL,FCL.ORG_ID_CLIENTE)
AND FCL.PER_ID_VENDEDOR = NVL(7647771,FCL.PER_ID_VENDEDOR)
AND FCL.CTV_CO_ESTADO_DOCUMENTO = 'EM'
AND FCL.UBG_ID_UBICACION_CLIENTE in (SELECT ID_REGISTRO
FROM S00_UBICACION_GEOGRAFICA
START WITH ID_REGISTRO = nvl(NULL, FCL.UBG_ID_UBICACION_CLIENTE)
CONNECT BY PRIOR ID_REGISTRO = UBG_ID_UBICACION_PADRE)
GROUP BY FCL.CTV_CO_CLASE_ORGANIZACION
,FCL.CTV_DE_CLASE_ORGANIZACION
,FCL.CO_ORGANIZACION
,FCL.ORG_NB_CLIENTE
,PER_CO_IDENTIFICACION_VENDEDOR
,PER_NB_PRIMER_NOMBRE_VENDEDOR||' '||
PER_NB_PRIMER_APELLIDO_VEND) VTA
,(SELECT NDC .CTV_CO_CLASE_ORGANIZACION CO_CLASE_CLIENTE
,NDC.CTV_DE_CLASE_ORGANIZACION DE_CLASE_CLIENTE
,NDC.CO_CLIENTE
,NDC.ORG_NB_CLIENTE NB_CLIENTE
,FCL.PER_CO_IDENTIFICACION_VENDEDOR CO_VENDEDOR
,FCL.PER_NB_PRIMER_NOMBRE_VENDEDOR||' '||
FCL.PER_NB_PRIMER_APELLIDO_VEND NB_VENDEDOR
,SUM(CA_PRODUCTO * (PR_PRODUCTO - NVL(PR_DESCUENTO_PRODUCTO,0))) MN_DEVUELTO
FROM S06_NOTA_DEBITO_CREDITO_TOT_R NDC
,S06_DETALLE_NOTA_DEB_CRED_TOT DND
,S04_FACTURA_CLIENTE_TOTAL_R FCL
WHERE NDC.ID_REGISTRO = DND.NDC_ID_NOTA_DEBITO_CREDITO
AND NDC.CTV_CO_TIPO_DOCUMENTO = SK00_BUSCAR.F_VCT('CO_TIPO_DOCUMENTO_NOTA_CREDITO_FISCAL')
AND NDC.CTV_CO_ESTADO_DOCUMENTO = SK00_BUSCAR.F_VCT('CO_ESTADO_DOCUMENTO_EMITIDO')
AND NDC.FE_EMISION BETWEEN to_date('01112009','ddmmyyyy') AND to_date('29112009','ddmmyyyy')
AND (NDC.CTV_CO_MOTIVO_NOTA = SK00_BUSCAR.F_VCT('CO_MOTIVO_NOE_DEVOLUCION')
OR NDC.CTV_CO_MOTIVO_NOTA = SK00_BUSCAR.F_VCT('CO_MOTIVO_AJUSTE_PRECIO_NCD'))
AND NDC.ORG_ID_CLIENTE = NVL(NULL,NDC.ORG_ID_CLIENTE)
AND FCL.ID_REGISTRO = NDC.FAC_ID_FACTURA
AND FCL.CTV_CO_ESTADO_DOCUMENTO = 'EM'
AND FCL.UBG_ID_UBICACION_CLIENTE in (SELECT ID_REGISTRO
FROM S00_UBICACION_GEOGRAFICA
START WITH ID_REGISTRO = nvl(NULL, FCL.UBG_ID_UBICACION_CLIENTE)
CONNECT BY PRIOR ID_REGISTRO = UBG_ID_UBICACION_PADRE)
GROUP BY NDC.CTV_CO_CLASE_ORGANIZACION
,NDC.CTV_DE_CLASE_ORGANIZACION
,NDC.CO_CLIENTE
,NDC.ORG_NB_CLIENTE
,FCL.PER_CO_IDENTIFICACION_VENDEDOR
,FCL.PER_NB_PRIMER_NOMBRE_VENDEDOR||' '||
FCL.PER_NB_PRIMER_APELLIDO_VEND) DEV
,(SELECT RCD .CTV_CO_CLASE_ORGANIZACION CO_CLASE_CLIENTE
,RCD.CTV_DE_CLASE_ORGANIZACION DE_CLASE_CLIENTE
,RCD.CO_ORGANIZACION CO_CLIENTE
,RCD.ORG_NB_DISTRIBUIDOR NB_CLIENTE
,FCL.PER_CO_IDENTIFICACION_VENDEDOR CO_VENDEDOR
,FCL.PER_NB_PRIMER_NOMBRE_VENDEDOR||' '||
FCL.PER_NB_PRIMER_APELLIDO_VEND NB_VENDEDOR
,SUM(RCD.MN_DESCUENTO) MN_DESCUENTO
,SUM(DECODE(SIGN(RCO.MN_COBRADO_ANTES - IVA.MN_IVA)
,-1
,RCD.MN_ABONO - ABS(RCO.MN_COBRADO_ANTES - IVA.MN_IVA)
,RCD.MN_ABONO)) MN_COBRADO
FROM S06_RECIBO_COBRO_DOC_TOTAL_R RCD
,S04_FACTURA_CLIENTE_TOTAL_R FCL
,(SELECT ID_DOCUMENTO_REFERENCIA FAC_ID_FACTURA
,NVL(SUM(MN_DEBITO_CREDITO),0) MN_IVA
FROM S04_DOCUMENTO_DEBITO_CREDITO_R
WHERE TDC_CO_TIPO_DEBITO_CREDITO = SK00_BUSCAR.F_VCT('CO_TIPO_DEBITO_IVA')
GROUP BY ID_DOCUMENTO_REFERENCIA) IVA
,(SELECT ID_REFERENCIA FAC_ID_FACTURA
,NVL(SUM(MN_ABONO),0) MN_COBRADO_ANTES
FROM S06_RECIBO_COBRO_DOC_TOTAL_R
WHERE FE_EMISION < to_date('01112009','ddmmyyyy')
GROUP BY ID_REFERENCIA) RCO
WHERE RCD.CTV_CO_ESTADO_DOCUMENTO = SK00_BUSCAR.F_VCT('CO_ESTADO_DOCUMENTO_EMITIDO')
AND RCD.FE_EMISION BETWEEN to_date('01112009','ddmmyyyy') AND to_date('29112009','ddmmyyyy')
AND RCD.ORG_ID_ORGANIZACION = NVL(NULL,RCD.ORG_ID_ORGANIZACION)
AND FCL.CTV_CO_ESTADO_DOCUMENTO = 'EM'
AND FCL.ID_REGISTRO = RCD.ID_REFERENCIA
AND FCL.UBG_ID_UBICACION_CLIENTE in (SELECT ID_REGISTRO
FROM S00_UBICACION_GEOGRAFICA
START WITH ID_REGISTRO = nvl(NULL, FCL.UBG_ID_UBICACION_CLIENTE)
CONNECT BY PRIOR ID_REGISTRO = UBG_ID_UBICACION_PADRE)
AND IVA.FAC_ID_FACTURA (+) = FCL.ID_REGISTRO
AND RCO.FAC_ID_FACTURA (+) = FCL.ID_REGISTRO
GROUP BY RCD.CTV_CO_CLASE_ORGANIZACION
,RCD.CTV_DE_CLASE_ORGANIZACION
,RCD.CO_ORGANIZACION
,RCD.ORG_NB_DISTRIBUIDOR
,FCL.PER_CO_IDENTIFICACION_VENDEDOR
,FCL.PER_NB_PRIMER_NOMBRE_VENDEDOR||' '||
FCL.PER_NB_PRIMER_APELLIDO_VEND) COB
WHERE VTA.CO_CLIENTE = DEV.CO_CLIENTE (+)
AND VTA.CO_VENDEDOR = DEV.CO_VENDEDOR (+)
AND VTA.CO_CLIENTE = COB.CO_CLIENTE (+)
AND VTA.CO_VENDEDOR = COB.CO_VENDEDOR (+)
ORDER BY VTA.NB_VENDEDOR
,VTA.CO_CLIENTE
Is there a way i can influence the join method on this query ...?
It's an XE DB.
Regards, Luis ...!THIS IS THE PLAN:
SQL> /
Execution Plan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=79006 Card=1 Bytes
=253)
1 0 SORT (ORDER BY) (Cost=79006 Card=1 Bytes=253)
2 1 HASH JOIN (OUTER) (Cost=79005 Card=1 Bytes=253)
3 2 HASH JOIN (OUTER) (Cost=78538 Card=1 Bytes=211)
4 3 VIEW (Cost=78478 Card=1 Bytes=182)
5 4 HASH (GROUP BY) (Cost=78478 Card=1 Bytes=232)
6 5 FILTER
7 6 HASH JOIN (OUTER) (Cost=78469 Card=1 Bytes=232
8 7 TABLE ACCESS (BY INDEX ROWID) OF 'T04_FACTUR
A_PRODUCTO' (TABLE) (Cost=2 Card=1 Bytes=46)
9 8 NESTED LOOPS (Cost=25 Card=1 Bytes=213)
10 9 VIEW OF 'V04_FACTURA_CLIENTE_TOTAL_R' (V
IEW) (Cost=23 Card=1 Bytes=167)
11 10 NESTED LOOPS (Cost=23 Card=1 Bytes=284
12 11 NESTED LOOPS (OUTER) (Cost=23 Card=1
Bytes=278)
13 12 HASH JOIN (SEMI) (Cost=23 Card=1 B
ytes=272)
14 13 NESTED LOOPS (Cost=17 Card=1 Byt
es=259)
15 14 NESTED LOOPS (Cost=16 Card=1 B
ytes=218)
16 15 NESTED LOOPS (OUTER) (Cost=1
6 Card=1 Bytes=212)
17 16 NESTED LOOPS (Cost=15 Card
=1 Bytes=179)
18 17 NESTED LOOPS (Cost=15 Ca
rd=1 Bytes=173)
19 18 NESTED LOOPS (OUTER) (
Cost=14 Card=1 Bytes=162)
20 19 NESTED LOOPS (OUTER)
(Cost=14 Card=1 Bytes=156)
21 20 NESTED LOOPS (OUTE
R) (Cost=14 Card=1 Bytes=150)
22 21 NESTED LOOPS (OU
TER) (Cost=14 Card=1 Bytes=144)
23 22 NESTED LOOPS (
Cost=14 Card=1 Bytes=105)
24 23 SORT (UNIQUE
) (Cost=2 Card=1 Bytes=13)
25 24 TABLE ACCE
SS (FULL) OF 'T00_GRUPO_DATO_USUARIO_ACTIVO' (TABLE (TEMP))
(Cost=2 Card=1 Bytes=13)
26 23 TABLE ACCESS
(BY INDEX ROWID) OF 'T04_FACTURA' (TABLE) (Cost=11 Card=1 B
ytes=92)
27 26 INDEX (RAN
GE SCAN) OF 'I04_FAC_FE_EMISION' (INDEX) (Cost=10 Card=2)
28 22 TABLE ACCESS (
BY INDEX ROWID) OF 'T03_EMPRESA_SUCURSAL' (TABLE) (Cost=0 Ca
rd=1 Bytes=39)
29 28 INDEX (RANGE
SCAN) OF 'I03_EMS_EMP' (INDEX) (Cost=0 Card=1)
30 21 INDEX (UNIQUE SC
AN) OF 'PK_PRY' (INDEX (UNIQUE)) (Cost=0 Card=1 Bytes=6)
31 20 INDEX (UNIQUE SCAN
) OF 'PK_CAJ' (INDEX (UNIQUE)) (Cost=0 Card=1 Bytes=6)
32 19 INDEX (UNIQUE SCAN)
OF 'PK_PEC' (INDEX (UNIQUE)) (Cost=0 Card=1 Bytes=6)
33 18 TABLE ACCESS (BY INDEX
ROWID) OF 'T00_CONTENIDO_TABLA_VIRTUAL' (TABLE) (Cost=1 Car
d=1 Bytes=11)
34 33 INDEX (UNIQUE SCAN)
OF 'PK_CTV' (INDEX (UNIQUE)) (Cost=0 Card=1)
SORRY EXPLAIN OUTPUT TRUNCATED DUE TO SPACE RESTRICION .....
Any help would be greatly appreciated.
I believe there must be a way to influence on the tha costly HASH JOIN operation
SQL> SPOOL OFF -
solved need help in tuning this Query
hi frs,
i have created a query like this
pls help
Regards
Rajesh
Message was edited by:
Rajesh.mani
Message was edited by:
Rajesh.maniCode and explain plan should be between [pre] and [/pre] or [code] and [/code] tags like this.
[pre]Code[/pre]An now explain plan
[code]Execution plan
[/code]
Cheers
Sarma. -
Plz help in tuning this query......
SELECT "LAN","VEF_REF_NO","VF_TYPE_CODE","APPLICANT_TYPE","MANDATORY","OPTIONAL","COMPLETE","DT_COMPLETED","REFIRENO","ROLE","USER_ID","DT_LASTUPDATED","TEMPLATEFIRED"
FROM T_VER_STRATEGY_DETAILS M
WHERE VF_TYPE_CODE =1 AND
APPLICANT_TYPE ='A' AND
DT_LASTUPDATED=
(SELECT MAX(DT_LASTUPDATED)
FROM T_VER_STRATEGY_DETAILS
WHERE LAN = M.LAN AND
VF_TYPE_CODE =1 AND APPLICANT_TYPE ='A')
This seems to be a correlated query.
i tried using combined index on
(VF_TYPE_CODE ,APPLICANT_TYPE ,DT_LASTUPDATED)
and another index on
(LAN,VF_TYPE_CODE ,APPLICANT_TYPE ) but the plan or cost remains unchained.
plz help[url http://forums.oracle.com/forums/thread.jspa?threadID=501834&tstart=0]When your query takes too long...
-
Please help me tuning this query...
Hi all,
Can any body suggest some changes (synthatic) so that it can improve its performance... taking too much time...
This is a query used in oracle report...
SELECT distinct cc.seg1,cc.seg2,cc.seg3,cc.seg4,cc.seg5,cc.seg6,cc.seg7,cc.seg8,cc.code_combination_id code_comb_id,
r.flex_validation_rule_name cv_rule,gl.currency_code currency1,
(NVL (gjl.accounted_dr, 0) - NVL (gjl.accounted_cr, 0)) trans_amount,
gjh.doc_sequence_value doc_num,
gjs.user_je_source_name je_source, gjc.user_je_category_name je_category,
fu.user_name last_updated_by,(NVL (gb.begin_balance_dr, 0)
- NVL (gb.begin_balance_cr, 0))
+ (NVL (gb.period_net_dr_beq, 0)
- NVL (gb.period_net_cr_beq, 0)) balance,
gjh.last_update_date last_updated_date,gjl.effective_date
FROM gl_code_combinations cc,
fnd_flex_vdation_rules_vl r,
fnd_flex_validation_rule_lines l,
gl_je_headers gjh,
gl_je_lines gjl,
gl_balances gb,
fnd_user fu,
gl_je_categories gjc,
gl_je_sources gjs,
gl_ledgers gl
WHERE cc.enabled_flag = 'Y'
AND NVL (cc.end_date_active, SYSDATE + 1) > SYSDATE
AND cc.chart_of_accounts_id = :p_chart_of_accounts_id
AND r.id_flex_num = cc.chart_of_accounts_id
AND r.id_flex_code = 'GL#'
AND r.application_id = 101
AND gjs.je_source_name=gjh.je_source
AND gjc.je_category_name=gjh.je_category
AND l.application_id = r.application_id
AND gb.code_combination_id=cc.code_combination_id
AND gjh.period_name=gb.period_name
AND r.enabled_flag = 'Y'
AND NVL (r.end_date_active, SYSDATE + 1) > SYSDATE
AND l.id_flex_code = r.id_flex_code
AND l.id_flex_num = r.id_flex_num
AND l.flex_validation_rule_name = r.flex_validation_rule_name
AND l.include_exclude_indicator = 'E'
AND gjl.code_combination_id = gb.code_combination_id
AND gjh.je_header_id = gjl.je_header_id
AND gjh.status = 'P'
AND gl.ledger_id=gjh.ledger_id
and gl.ledger_id=:p_ledger_id
AND gjh.last_updated_by = fu.user_id
and (gjh.last_update_date,gjl.last_update_date)=(
SELECT MAX (a.last_update_date) ,MAX(b.last_update_date)
FROM gl_je_headers a, gl_je_lines b
WHERE b.code_combination_id = cc.code_combination_id
AND a.je_header_id = b.je_header_id
AND a.status = 'P'
AND ROWNUM = 1)
and (NVL (gjl.accounted_dr, 0) - NVL (gjl.accounted_cr, 0))=(select (NVL (accounted_dr, 0) - NVL (accounted_cr, 0)) from gl_je_lines
where je_header_id=gjh.je_header_id and code_combination_id=cc.code_combination_id and period_name=gjh.period_name and
last_update_date=gjh.last_update_date and rownum=1)
and (NVL (gb.begin_balance_dr, 0)
- NVL (gb.begin_balance_cr, 0))
+ (NVL (gb.period_net_dr_beq, 0)
- NVL (gb.period_net_cr_beq, 0))=(select max((NVL (begin_balance_dr, 0)
- NVL (begin_balance_cr, 0))
+ (NVL (period_net_dr_beq, 0)
- NVL (period_net_cr_beq, 0))) from gl_balances where code_combination_id=cc.code_combination_id
and period_name=gb.period_name)
and gjl.description=(select description from gl_je_lines where code_combination_id=cc.code_combination_id and
je_header_id=gjh.je_header_id and period_name=gb.period_name and rownum=1)
AND cc.seg1 BETWEEN NVL (SUBSTR (l.concatenated_segments_low, 1, 3),
cc.seg1
AND NVL (SUBSTR (l.concatenated_segments_high, 1, 3),
cc.seg1
AND cc.seg2 BETWEEN NVL (SUBSTR (l.concatenated_segments_low, 5, 4),
cc.seg2
AND NVL (SUBSTR (l.concatenated_segments_high, 5, 4),
cc.seg2
AND cc.seg3 BETWEEN NVL (SUBSTR (l.concatenated_segments_low, 10, 4),
cc.segt3
AND NVL (SUBSTR (l.concatenated_segments_high, 10, 4),
cc.seg3
AND cc.seg4 BETWEEN NVL (SUBSTR (l.concatenated_segments_low, 15, 3),
cc.seg4
AND NVL (SUBSTR (l.concatenated_segments_high, 15, 3),
cc.seg4
AND cc.seg5 BETWEEN NVL (SUBSTR (l.concatenated_segments_low, 19, 6),
cc.seg5
AND NVL (SUBSTR (l.concatenated_segments_high, 19, 6),
cc.seg5
AND cc.seg6 BETWEEN NVL (SUBSTR (l.concatenated_segments_low, 26, 4),
cc.segment6
AND NVL (SUBSTR (l.concatenated_segments_high, 26, 4),
cc.seg6
AND cc.seg7 BETWEEN NVL (SUBSTR (l.concatenated_segments_low, 31, 6),
cc.seg7
AND NVL (SUBSTR (l.concatenated_segments_high, 31, 6),
cc.seg7
AND cc.seg8 BETWEEN NVL (SUBSTR (l.concatenated_segments_low, 38, 6),
cc.seg8
AND NVL (SUBSTR (l.concatenated_segments_high, 38, 6),
cc.seg8)Thanks for help
aspDear all,
the folliwing is explain plan for above query...
<ExplainPlan>
- <PlanElement object_ID="0" id="0" operation="SELECT STATEMENT" optimizer="ALL_ROWS" cost="1,417" cardinality="1" bytes="477" cpu_cost="263,995,086" io_cost="1,385" time="18">
- <PlanElements>
- <PlanElement object_ID="0" id="1" operation="HASH" option="UNIQUE" cost="1,417" cardinality="1" bytes="477" cpu_cost="263,995,086" io_cost="1,385" time="18">
- <PlanElements>
- <PlanElement object_ID="0" id="2" operation="FILTER" filter_predicates="("GJH"."LAST_UPDATE_DATE","GJL"."LAST_UPDATE_DATE")= (SELECT MAX("A"."LAST_UPDATE_DATE"),MAX("B"."LAST_UPDATE_DATE") FROM "GL"."GL_JE_LINES" "B","GL"."GL_JE_HEADERS" "A" WHERE ROWNUM=1 AND "A"."JE_HEADER_ID"="B"."JE_HEADER_ID" AND "A"."STATUS"='P' AND "B"."CODE_COMBINATION_ID"=:B1) AND NVL("GJL"."ACCOUNTED_DR",0)-NVL("GJL"."ACCOUNTED_CR",0)= (SELECT NVL("ACCOUNTED_DR",0)-NVL("ACCOUNTED_CR",0) FROM "GL"."GL_JE_LINES" "GL_JE_LINES" WHERE ROWNUM=1 AND "PERIOD_NAME"=:B2 AND "CODE_COMBINATION_ID"=:B3 AND "JE_HEADER_ID"=:B4 AND "LAST_UPDATE_DATE"=:B5) AND NVL("GB"."BEGIN_BALANCE_DR",0)-NVL("GB"."BEGIN_BALANCE_CR",0)+(NVL("GB"."PERIOD_NET_DR_BEQ",0)-NVL("GB"."PERIOD_NET_CR_BEQ",0))= (SELECT MAX(NVL("BEGIN_BALANCE_DR",0)-NVL("BEGIN_BALANCE_CR",0)+(NVL("PERIOD_NET_DR_BEQ",0)-NVL("PERIOD_NET_CR_BEQ",0))) FROM "GL"."GL_BALANCES" "GL_BALANCES" WHERE "PERIOD_NAME"=:B6 AND "CODE_COMBINATION_ID"=:B7)">
- <PlanElements>
- <PlanElement object_ID="0" id="3" operation="NESTED LOOPS" cost="1,262" cardinality="1" bytes="477" cpu_cost="254,376,045" io_cost="1,231" time="16">
- <PlanElements>
- <PlanElement object_ID="0" id="4" operation="NESTED LOOPS" cost="1,261" cardinality="1" bytes="464" cpu_cost="254,366,853" io_cost="1,230" time="16">
- <PlanElements>
- <PlanElement object_ID="0" id="5" operation="NESTED LOOPS" cost="1,260" cardinality="1" bytes="433" cpu_cost="254,357,622" io_cost="1,229" time="16">
- <PlanElements>
- <PlanElement object_ID="0" id="6" operation="NESTED LOOPS" cost="1,259" cardinality="1" bytes="402" cpu_cost="254,348,331" io_cost="1,228" time="16">
- <PlanElements>
- <PlanElement object_ID="0" id="7" operation="NESTED LOOPS" cost="1,258" cardinality="1" bytes="350" cpu_cost="254,337,522" io_cost="1,227" time="16">
- <PlanElements>
- <PlanElement object_ID="0" id="8" operation="NESTED LOOPS" cost="1,239" cardinality="1" bytes="273" cpu_cost="254,166,811" io_cost="1,208" time="15">
- <PlanElements>
- <PlanElement object_ID="0" id="9" operation="HASH JOIN" cost="1,184" cardinality="1" bytes="248" cpu_cost="253,727,112" io_cost="1,153" access_predicates=""B"."ID_FLEX_NUM"="CC"."CHART_OF_ACCOUNTS_ID"" filter_predicates=""CC"."SEGMENT1">=NVL(SUBSTR("L"."CONCATENATED_SEGMENTS_LOW",1,3),"CC"."SEGMENT1") AND "CC"."SEGMENT1"<=NVL(SUBSTR("L"."CONCATENATED_SEGMENTS_HIGH",1,3),"CC"."SEGMENT1") AND "CC"."SEGMENT2">=NVL(SUBSTR("L"."CONCATENATED_SEGMENTS_LOW",5,4),"CC"."SEGMENT2") AND "CC"."SEGMENT2"<=NVL(SUBSTR("L"."CONCATENATED_SEGMENTS_HIGH",5,4),"CC"."SEGMENT2") AND "CC"."SEGMENT3">=NVL(SUBSTR("L"."CONCATENATED_SEGMENTS_LOW",10,4),"CC"."SEGMENT3") AND "CC"."SEGMENT3"<=NVL(SUBSTR("L"."CONCATENATED_SEGMENTS_HIGH",10,4),"CC"."SEGMENT3") AND "CC"."SEGMENT4">=NVL(SUBSTR("L"."CONCATENATED_SEGMENTS_LOW",15,3),"CC"."SEGMENT4") AND "CC"."SEGMENT4"<=NVL(SUBSTR("L"."CONCATENATED_SEGMENTS_HIGH",15,3),"CC"."SEGMENT4") AND "CC"."SEGMENT5">=NVL(SUBSTR("L"."CONCATENATED_SEGMENTS_LOW",19,6),"CC"."SEGMENT5") AND "CC"."SEGMENT5"<=NVL(SUBSTR("L"."CONCATENATED_SEGMENTS_HIGH",19,6),"CC"."SEGMENT5") AND "CC"."SEGMENT6">=NVL(SUBSTR("L"."CONCATENATED_SEGMENTS_LOW",26,4),"CC"."SEGMENT6") AND "CC"."SEGMENT6"<=NVL(SUBSTR("L"."CONCATENATED_SEGMENTS_HIGH",26,4),"CC"."SEGMENT6") AND "CC"."SEGMENT7">=NVL(SUBSTR("L"."CONCATENATED_SEGMENTS_LOW",31,6),"CC"."SEGMENT7") AND "CC"."SEGMENT7"<=NVL(SUBSTR("L"."CONCATENATED_SEGMENTS_HIGH",31,6),"CC"."SEGMENT7") AND "CC"."SEGMENT8">=NVL(SUBSTR("L"."CONCATENATED_SEGMENTS_LOW",38,6),"CC"."SEGMENT8") AND "CC"."SEGMENT8"<=NVL(SUBSTR("L"."CONCATENATED_SEGMENTS_HIGH",38,6),"CC"."SEGMENT8")" time="15">
- <PlanElements>
- <PlanElement object_ID="1" id="10" operation="TABLE ACCESS" option="BY INDEX ROWID" optimizer="ANALYZED" object_owner="APPLSYS" object_name="FND_FLEX_VALIDATION_RULE_LINES" object_type="TABLE" object_instance="3" cost="3" cardinality="1" bytes="119" cpu_cost="49,909" io_cost="3" filter_predicates=""L"."INCLUDE_EXCLUDE_INDICATOR"='E'" time="1">
- <PlanElements>
- <PlanElement object_ID="0" id="11" operation="NESTED LOOPS" cost="6" cardinality="1" bytes="189" cpu_cost="75,588" io_cost="6" time="1">
- <PlanElements>
- <PlanElement object_ID="0" id="12" operation="NESTED LOOPS" cost="3" cardinality="1" bytes="70" cpu_cost="25,679" io_cost="3" time="1">
- <PlanElements>
- <PlanElement object_ID="0" id="13" operation="NESTED LOOPS" cost="3" cardinality="1" bytes="39" cpu_cost="23,779" io_cost="3" time="1">
- <PlanElements>
- <PlanElement object_ID="2" id="14" operation="TABLE ACCESS" option="BY INDEX ROWID" optimizer="ANALYZED" object_owner="GL" object_name="GL_LEDGERS" object_type="TABLE" object_instance="10" cost="1" cardinality="1" bytes="8" cpu_cost="8,541" io_cost="1" time="1">
- <PlanElements>
<PlanElement object_ID="3" id="15" operation="INDEX" option="UNIQUE SCAN" optimizer="ANALYZED" object_owner="GL" object_name="GL_LEDGERS_U2" object_type="INDEX (UNIQUE)" search_columns="1" cost="0" cardinality="1" cpu_cost="1,050" io_cost="0" access_predicates=""GL"."LEDGER_ID"=TO_NUMBER(:P_LEDGER_ID)" time="1" />
</PlanElements>
</PlanElement>
- <PlanElement object_ID="4" id="16" operation="TABLE ACCESS" option="BY INDEX ROWID" optimizer="ANALYZED" object_owner="APPLSYS" object_name="FND_FLEX_VALIDATION_RULES" object_type="TABLE" object_instance="19" cost="2" cardinality="1" bytes="31" cpu_cost="15,238" io_cost="2" filter_predicates=""B"."ENABLED_FLAG"='Y' AND NVL("B"."END_DATE_ACTIVE",SYSDATE@!+1)>SYSDATE@!" time="1">
- <PlanElements>
<PlanElement object_ID="5" id="17" operation="INDEX" option="RANGE SCAN" optimizer="ANALYZED" object_owner="APPLSYS" object_name="FND_FLEX_VALIDATION_RULES_U1" object_type="INDEX (UNIQUE)" search_columns="3" cost="1" cardinality="1" cpu_cost="7,321" io_cost="1" access_predicates=""B"."APPLICATION_ID"=101 AND "B"."ID_FLEX_CODE"='GL#' AND "B"."ID_FLEX_NUM"=TO_NUMBER(:P_CHART_OF_ACCOUNTS_ID)" time="1" />
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
<PlanElement object_ID="6" id="18" operation="INDEX" option="UNIQUE SCAN" optimizer="ANALYZED" object_owner="APPLSYS" object_name="FND_FLEX_VDATION_RULES_TL_U1" object_type="INDEX (UNIQUE)" search_columns="5" cost="0" cardinality="1" bytes="31" cpu_cost="1,900" io_cost="0" access_predicates=""T"."APPLICATION_ID"=101 AND "T"."ID_FLEX_CODE"='GL#' AND "T"."ID_FLEX_NUM"=TO_NUMBER(:P_CHART_OF_ACCOUNTS_ID) AND "B"."FLEX_VALIDATION_RULE_NAME"="T"."FLEX_VALIDATION_RULE_NAME" AND "T"."LANGUAGE"=USERENV('LANG')" time="1" />
</PlanElements>
</PlanElement>
<PlanElement object_ID="7" id="19" operation="INDEX" option="RANGE SCAN" optimizer="ANALYZED" object_owner="APPLSYS" object_name="FND_FLEX_VAL_RULE_LINES_N1" object_type="INDEX" search_columns="4" cost="1" cardinality="41" cpu_cost="16,371" io_cost="1" access_predicates=""L"."APPLICATION_ID"=101 AND "L"."ID_FLEX_CODE"='GL#' AND "L"."ID_FLEX_NUM"=TO_NUMBER(:P_CHART_OF_ACCOUNTS_ID) AND "L"."FLEX_VALIDATION_RULE_NAME"="B"."FLEX_VALIDATION_RULE_NAME"" time="1" />
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
<PlanElement object_ID="8" id="20" operation="TABLE ACCESS" option="FULL" optimizer="ANALYZED" object_owner="GL" object_name="GL_CODE_COMBINATIONS" object_type="TABLE" object_instance="1" cost="1,177" cardinality="1,088" bytes="64,192" cpu_cost="249,419,570" io_cost="1,147" filter_predicates=""CC"."ENABLED_FLAG"='Y' AND "CC"."CHART_OF_ACCOUNTS_ID"=TO_NUMBER(:P_CHART_OF_ACCOUNTS_ID) AND NVL("CC"."END_DATE_ACTIVE",SYSDATE@!+1)>SYSDATE@!" time="15" />
</PlanElements>
</PlanElement>
- <PlanElement object_ID="9" id="21" operation="TABLE ACCESS" option="BY INDEX ROWID" optimizer="ANALYZED" object_owner="GL" object_name="GL_BALANCES" object_type="TABLE" object_instance="6" cost="55" cardinality="52" bytes="1,300" cpu_cost="439,699" io_cost="55" time="1">
- <PlanElements>
<PlanElement object_ID="10" id="22" operation="INDEX" option="RANGE SCAN" optimizer="ANALYZED" object_owner="GL" object_name="GL_BALANCES_N1" object_type="INDEX" search_columns="1" cost="2" cardinality="52" cpu_cost="25,693" io_cost="2" access_predicates=""GB"."CODE_COMBINATION_ID"="CC"."CODE_COMBINATION_ID"" time="1" />
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
- <PlanElement object_ID="11" id="23" operation="TABLE ACCESS" option="BY INDEX ROWID" optimizer="ANALYZED" object_owner="GL" object_name="GL_JE_LINES" object_type="TABLE" object_instance="5" cost="19" cardinality="40" bytes="3,080" cpu_cost="170,710" io_cost="19" time="1">
- <PlanElements>
<PlanElement object_ID="12" id="24" operation="INDEX" option="RANGE SCAN" optimizer="ANALYZED" object_owner="GL" object_name="GL_JE_LINES_N1" object_type="INDEX" search_columns="1" cost="2" cardinality="49" cpu_cost="24,693" io_cost="2" access_predicates=""GJL"."CODE_COMBINATION_ID"="GB"."CODE_COMBINATION_ID"" time="1" />
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
- <PlanElement object_ID="13" id="25" operation="TABLE ACCESS" option="BY INDEX ROWID" optimizer="ANALYZED" object_owner="GL" object_name="GL_JE_HEADERS" object_type="TABLE" object_instance="4" cost="1" cardinality="1" bytes="52" cpu_cost="10,809" io_cost="1" filter_predicates=""GJH"."STATUS"='P' AND "GJH"."LEDGER_ID"=TO_NUMBER(:P_LEDGER_ID) AND "GJH"."PERIOD_NAME"="GB"."PERIOD_NAME"" time="1">
- <PlanElements>
- <PlanElement object_ID="14" id="26" operation="INDEX" option="UNIQUE SCAN" optimizer="ANALYZED" object_owner="GL" object_name="GL_JE_HEADERS_U1" object_type="INDEX (UNIQUE)" search_columns="1" cost="0" cardinality="1" cpu_cost="1,950" io_cost="0" access_predicates=""GJH"."JE_HEADER_ID"="GJL"."JE_HEADER_ID"" filter_predicates=""GJL"."DESCRIPTION"= (SELECT "DESCRIPTION" FROM "GL"."GL_JE_LINES" "GL_JE_LINES" WHERE ROWNUM=1 AND "PERIOD_NAME"=:B1 AND "CODE_COMBINATION_ID"=:B2 AND "JE_HEADER_ID"=:B3)" time="1">
- <PlanElements>
- <PlanElement object_ID="0" id="27" operation="COUNT" option="STOPKEY" filter_predicates="ROWNUM=1">
- <PlanElements>
- <PlanElement object_ID="11" id="28" operation="TABLE ACCESS" option="BY INDEX ROWID" optimizer="ANALYZED" object_owner="GL" object_name="GL_JE_LINES" object_type="TABLE" object_instance="15" cost="5" cardinality="1" bytes="62" cpu_cost="39,168" io_cost="5" filter_predicates=""JE_HEADER_ID"=:B1" time="1">
- <PlanElements>
<PlanElement object_ID="12" id="29" operation="INDEX" option="RANGE SCAN" optimizer="ANALYZED" object_owner="GL" object_name="GL_JE_LINES_N1" object_type="INDEX" search_columns="2" cost="3" cardinality="4" cpu_cost="22,364" io_cost="3" access_predicates=""CODE_COMBINATION_ID"=:B1 AND "PERIOD_NAME"=:B2" time="1" />
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
- <PlanElement object_ID="15" id="30" operation="TABLE ACCESS" option="BY INDEX ROWID" optimizer="ANALYZED" object_owner="GL" object_name="GL_JE_SOURCES_TL" object_type="TABLE" object_instance="16" cost="1" cardinality="2" bytes="62" cpu_cost="9,291" io_cost="1" time="1">
- <PlanElements>
<PlanElement object_ID="16" id="31" operation="INDEX" option="UNIQUE SCAN" optimizer="ANALYZED" object_owner="GL" object_name="GL_JE_SOURCES_TL_U1" object_type="INDEX (UNIQUE)" search_columns="2" cost="0" cardinality="1" cpu_cost="1,900" io_cost="0" access_predicates=""JE_SOURCE_NAME"="GJH"."JE_SOURCE" AND "LANGUAGE"=USERENV('LANG')" time="1" />
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
- <PlanElement object_ID="17" id="32" operation="TABLE ACCESS" option="BY INDEX ROWID" optimizer="ANALYZED" object_owner="GL" object_name="GL_JE_CATEGORIES_TL" object_type="TABLE" object_instance="17" cost="1" cardinality="2" bytes="62" cpu_cost="9,231" io_cost="1" time="1">
- <PlanElements>
<PlanElement object_ID="18" id="33" operation="INDEX" option="UNIQUE SCAN" optimizer="ANALYZED" object_owner="GL" object_name="GL_JE_CATEGORIES_TL_U1" object_type="INDEX (UNIQUE)" search_columns="2" cost="0" cardinality="1" cpu_cost="1,900" io_cost="0" access_predicates=""JE_CATEGORY_NAME"="GJH"."JE_CATEGORY" AND "LANGUAGE"=USERENV('LANG')" time="1" />
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
- <PlanElement object_ID="19" id="34" operation="TABLE ACCESS" option="BY INDEX ROWID" optimizer="ANALYZED" object_owner="APPLSYS" object_name="FND_USER" object_type="TABLE" object_instance="7" cost="1" cardinality="1" bytes="13" cpu_cost="9,191" io_cost="1" time="1">
- <PlanElements>
<PlanElement object_ID="20" id="35" operation="INDEX" option="UNIQUE SCAN" optimizer="ANALYZED" object_owner="APPLSYS" object_name="FND_USER_U1" object_type="INDEX (UNIQUE)" search_columns="1" cost="0" cardinality="1" cpu_cost="1,900" io_cost="0" access_predicates=""GJH"."LAST_UPDATED_BY"="FU"."USER_ID"" time="1" />
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
- <PlanElement object_ID="0" id="36" operation="SORT" option="AGGREGATE" cardinality="1" bytes="33">
- <PlanElements>
- <PlanElement object_ID="0" id="37" operation="COUNT" option="STOPKEY" filter_predicates="ROWNUM=1">
- <PlanElements>
- <PlanElement object_ID="0" id="38" operation="NESTED LOOPS" cost="69" cardinality="49" bytes="1,617" cpu_cost="624,699" io_cost="69" time="1">
- <PlanElements>
- <PlanElement object_ID="11" id="39" operation="TABLE ACCESS" option="BY INDEX ROWID" optimizer="ANALYZED" object_owner="GL" object_name="GL_JE_LINES" object_type="TABLE" object_instance="12" cost="20" cardinality="49" bytes="882" cpu_cost="164,029" io_cost="20" time="1">
- <PlanElements>
<PlanElement object_ID="12" id="40" operation="INDEX" option="RANGE SCAN" optimizer="ANALYZED" object_owner="GL" object_name="GL_JE_LINES_N1" object_type="INDEX" search_columns="1" cost="3" cardinality="49" cpu_cost="30,964" io_cost="3" access_predicates=""B"."CODE_COMBINATION_ID"=:B1" time="1" />
</PlanElements>
</PlanElement>
- <PlanElement object_ID="13" id="41" operation="TABLE ACCESS" option="BY INDEX ROWID" optimizer="ANALYZED" object_owner="GL" object_name="GL_JE_HEADERS" object_type="TABLE" object_instance="11" cost="1" cardinality="1" bytes="15" cpu_cost="9,401" io_cost="1" filter_predicates=""A"."STATUS"='P'" time="1">
- <PlanElements>
<PlanElement object_ID="14" id="42" operation="INDEX" option="UNIQUE SCAN" optimizer="ANALYZED" object_owner="GL" object_name="GL_JE_HEADERS_U1" object_type="INDEX (UNIQUE)" search_columns="1" cost="0" cardinality="1" cpu_cost="1,900" io_cost="0" access_predicates=""A"."JE_HEADER_ID"="B"."JE_HEADER_ID"" time="1" />
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
- <PlanElement object_ID="0" id="43" operation="COUNT" option="STOPKEY" filter_predicates="ROWNUM=1">
- <PlanElements>
- <PlanElement object_ID="11" id="44" operation="TABLE ACCESS" option="BY INDEX ROWID" optimizer="ANALYZED" object_owner="GL" object_name="GL_JE_LINES" object_type="TABLE" object_instance="13" cost="5" cardinality="1" bytes="33" cpu_cost="39,068" io_cost="5" filter_predicates=""JE_HEADER_ID"=:B1 AND "LAST_UPDATE_DATE"=:B2" time="1">
- <PlanElements>
<PlanElement object_ID="12" id="45" operation="INDEX" option="RANGE SCAN" optimizer="ANALYZED" object_owner="GL" object_name="GL_JE_LINES_N1" object_type="INDEX" search_columns="2" cost="3" cardinality="4" cpu_cost="22,364" io_cost="3" access_predicates=""CODE_COMBINATION_ID"=:B1 AND "PERIOD_NAME"=:B2" time="1" />
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
- <PlanElement object_ID="0" id="46" operation="SORT" option="AGGREGATE" cardinality="1" bytes="25">
- <PlanElements>
- <PlanElement object_ID="9" id="47" operation="TABLE ACCESS" option="BY INDEX ROWID" optimizer="ANALYZED" object_owner="GL" object_name="GL_BALANCES" object_type="TABLE" object_instance="14" cost="6" cardinality="1" bytes="25" cpu_cost="45,399" io_cost="6" time="1">
- <PlanElements>
<PlanElement object_ID="10" id="48" operation="INDEX" option="RANGE SCAN" optimizer="ANALYZED" object_owner="GL" object_name="GL_BALANCES_N1" object_type="INDEX" search_columns="2" cost="3" cardinality="2" cpu_cost="21,964" io_cost="3" access_predicates=""CODE_COMBINATION_ID"=:B1 AND "PERIOD_NAME"=:B2" time="1" />
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
</PlanElements>
</PlanElement>
</ExplainPlan>Sorry this xml generated...
Regards
asp -
Hi friends,
os
id
ot_id
ot
ot
os_id
I will be having more records for ot_id in the table os, now i want to update the max(id) from os for each ot_id in that table to the os_id in the ot table
help me in this pleaseUse MERGE :
merge into os a
using (select max(rowid) keep (dense_rank last order by id) rwd from os group by ot_id) b
on (a.rowid=b.rwd)
when matched then update set a.id = (select os_id from ot c where a.ot_id=c.ot);But maybe with a concret example we will be able to give you a better answer.
Nicolas. -
Need Help in tuning this query
select CO_PROFILE.CO_NO AS "UEN No.",
CO_PROFILE.CO_NAME AS "Entity Name",
DECODE(CO_PROFILE.CO_TYPE,'A1','PUBLIC COMPANY LIMITED BY SHARES',
'A3','COMPANY LIMITED BY GUARANTEE',
'A4','UNLIMITED PUBLIC COMPANY',
'B1','LIMITED PRIVATE COMPANY',
'B2','LIMITED EXEMPT PRIVATE COMPANY',
'B3','UNLIMITED PRIVATE COMPANY',
'B4','UNLIMITED EXEMPT PRIVATE COMPANY',
'F1','FOREIGN COMPANY REGISTERED IN SINGAPORE') AS "Entity Type",
M_STATUS.STATUS_DESC AS "Entity Status",
PAYMENT_DETAIL.SERVICE_CODE AS "Service Code",
PAYMENT_DETAIL.PAYMENT_CODE AS "Payment Code",
CO_TRANS_MAST.CO_TRANS_ID AS "Transaction Type",
M_PAYMENT_CODE.PAYMENT_DESC AS "Payment Description",
M_PAYMENT_CODE.REVENUE_CODE AS "Revenue Account",
CO_TRANS_MAST.NUM AS "Number Of Transactions",
PAY_NEW.UNIT_AMT AS "Revenue Amount1",
PAY_NEW.FILING_AMT AS "Revenue Amount2",
PAYMENT_DETAIL.UNIT_FEE AS "Unit Cost"
from CO_PROFILE,
M_STATUS,
PAYMENT_DETAIL,
CO_TRANS_MASTER,
(Select COUNT(CO_NO) AS "NUM",CO_TRANS_ID,CO_NO
from CO_TRANS_MASTER
group by CO_NO,CO_TRANS_ID
)CO_TRANS_MAST,
(Select Sum(UNIT_FEE) AS UNIT_AMT,
SUM(FILING_FEE) AS FILING_AMT,
TRANS_NO AS TRANS_NO
from
PAYMENT_DETAIL
group by
TRANS_NO)
PAY_NEW,
M_PAYMENT_CODE
where rownum=1
and CO_PROFILE.CO_STATUS=M_STATUS.STATUS_CODE
and M_STATUS.TRANS_ID='COMP'
and CO_TRANS_MASTER.CO_TRANS_ID=CO_TRANS_MAST.CO_TRANS_ID
and CO_TRANS_MASTER.CO_NO=CO_TRANS_MAST.CO_NO
and PAYMENT_DETAIL.TRANS_NO=CO_TRANS_MASTER.CO_TRANS_NO
and PAY_NEW.TRANS_NO=PAYMENT_DETAIL.TRANS_NO
and CO_TRANS_MAST.CO_NO= CO_PROFILE.CO_NO
and M_PAYMENT_CODE.PAYMENT_CODE=PAYMENT_DETAIL.PAYMENT_CODESomething seems wrong to me with the logical structure of the select.
1) You only get 1 row of output
but you
2) build sums for each trans_no
3) You join the table co_trans_master but at the same time you count over that one. Might be ok to do so, but it seems to be double the work.
Suggestion.
a) Build a select that joins the payment detail table. Then group this select and build the sums.
b) Add the count for the number of transactions to the select clause instead of and extra inline view in the from clause. Maybe as an analytical function if possible. -
Please can you help me in Tuning this query..?
Hi ,
Please can you help me in re-structuring this query? .Details are given below.
I have 2 tables as shown below and data is like this.
Position
COD IND
AAA N
BBB N
CCC N
DDD Y
Distance
orig dest
AAA BBB
BBB CCC
AAA CCC
I need to create the records like this
start end
DDD AAA
DDD BBB
DDD CCC
The query which i am using now for this is
select p.code AS start,
P1.CODE AS end
from position p, position p1
where
P.CODE != P1.CODE
AND (P.ind = 'Y' or P1.IND = 'Y')
AND not exists
(select 1
from distance d
where (d.orig = p.code or d.dest = p.code)
and (d.orig = p1.code or d.dest = p1.code))
table is having above a crore record. so its taking a lot of time.
Please someone please help in tuning this query?
Thanks and regards,
ShabirLooks like you want this
select a.strt, b.ends from
(select p.code strt from position p where p.ind='Y') a,
(select p.code ends from position p where p.ind='N') b
where not exists (select 1 from distance d where d.orig=a.strt or d.dest=a.strt);
DDD AAA
DDD BBB
DDD CCCYour query result is:
AAA DDD
BBB DDD
CCC DDD
DDD AAA
DDD BBB
DDD CCCYou should be more descriptive about what kind of result you want, so that people can get more interested in helping you.
Maybe you are looking for
-
Help with loadmovie in Flash 8
hi flashCoders, this code used to work fine in old versions but now doesn't work theres is the code: <--- _root.createEmptyMovieClip("fundo", 1); fundo.loadMovie("image3.jpg"); fotosArray = ["image1.jpg", "image3.jpg", "image7.jpg"]; function fotosRo
-
Using StringItem as a button(help)
When I implements ItemCommandListener(implements both CommandListener and ItemCommandListener) to my class,there's an error said that only abstract class can override the abstract method commandAction(),why?How to solve this problem?
-
After maverick update mac won't come out of sleep
After I updated to Mavericks my macbook pro wont come out of sleep modes, I will close the screen or let the computer go to sleep from inactivity and i can see that its breathing but it wont come out of sleep mode and than requires a hard shutdown. I
-
I seem to have lost(?) the driver of a USB device in re-loading windows XP. My research tells me it's possibly to run a sierra wireless mini-card. Where can i download it........this the last of about fifteen lost in the process of this escapade.....
-
My dad's imessage hacked by auction site
So this afternoon my dad sent me a weird text telling me about an auction site. So I'm guessing my dad's imessage was hacked by the auction site. Is there anyway to get rid of them? Btw, my dad, sister, and I have iphones. My dads is a iphone 4. Also