Rewrite the query without a clause EXISTS
I would like to know another way to write the query without the EXISTS clause below. The main problem is with the inner query not allowing Java Hibernate to cache the results of the query.Select max (wt.wtime) wttme
x wt.
PIA,
z g
where wt.vid = v.vid and
v.GID = g.gid and
g.gname = "XXX" and
not exists (select *)
x wt1.
y v1,.
z g1
where wt1.vid = v1.vid and
v1. GID = g1.gid and
G1.gname = "XXX" and
(wt1.last_updated < (sysdate-. 0013) or)
Upper (WT1. Error) '= t'
)
)
z / / DESC;
Name of Type Null
GID NOT NULL NUMBER
GNAME NOT NULL VARCHAR2 (100)
ACTIVE NON-NULL CHAR (1)
DATE OF UPDATE_DATE
UPDATED_BY VARCHAR2 (50)
GID GNAME UPDATE_DATE ACTIVE UPDATED_BY
1 XXX Y 6 July 09 14:50:24 Test
y / / DESC;
Name of Type Null
VID NOT NULL NUMBER
VNAME NOT NULL VARCHAR2 (100)
GID NOT NULL NUMBER
ACTIVE NON-NULL CHAR (1)
DATE OF UPDATE_DATE
UPDATED_BY VARCHAR2 (50)
VID VNAME GID UPDATE_DATE ACTIVE UPDATED_BY
1 ICT 1 Y 6 July 09 14:50:24 Test
arvato 2 1 O 6 July 09 14:50:24 Test
/ / DESC x;
Name of Type Null
VID NOT NULL NUMBER
NUMBER OF WTIME
ERROR VARCHAR2 (4000)
NOT CLOSED NULL CHAR (1)
LAST_UPDATED DATE
VID WTIME LAST_UPDATED CLOSED ERROR
1 65 N N 10 JUNE 09 00:00:00
2 23 N N AUGUST 10 09 00:00:00
Ken R says:
What I would like to have is a query WITHOUT a clause EXISTS and to implement INSIDE logical query * (wt1.last_updated< (sysdate="" -="" .0013)="" or="" upper(wt1.error)='T' )*="" in="" the="" outer="">
Well have a look at the two queries above then.
Tags: Database
Similar Questions
-
Rewrite the query without views
I remember seeing a function in oracle PL/SQL package, which would be to rewrite a query as it contained no views more (but the only real tables)... but I don't remember the name of the function.
What function/package for this?
Hello
looking for the new feature of 12 c DBMS_UTILITY. EXPAND_SQL_TEXT?
Concerning
Marcus
-
How to rewrite the query without inline query
Hello people,
I have this request trying to rewrite with a single outer join. As previously with the inline its taking too much time (one day). I was wondering if this is how I rewrite. Thanks to a bouquet. I know there must be indexed on the event.
Published by: user11961230 on May 2, 2012 12:28original : select e.event_id, EVENT_STATUS_CODE, EVENT_TYPE_CODE, c.client_code, trunc(DATE_EXTRACTED), trunc(DATE_SUBMITTED), trunc(CLS.DATE_RETURNED), trunc(DATE_TYPED), trunc(REJECT_DATE), SUM_BILLED "bill_ttl", SUM_PAID, SUM_AMOUNT "Recoveries", trunc(DATE_OF_INCIDENT), recspec.USER_REAL_NAME, recspec.LEVEL_B_CODE, trunc(STAGE_CREATED_DATE), REJECT_CODE, ISO_ERROR FROM EVENT E, CLIENT C, MV_RECOVERYDET_EVENT_SUM MV_R, CLS_SEND CLS, MV_BILLDETAIL_EVENT_SUM MV_BDE, (SELECT EVENT_ID, USER_REAL_NAME, LEVEL_B_CODE FROM END_USER EU, EVENT_END_USER EEU WHERE EEU.END_USER_ID = EU.END_USER_ID AND OWNER_FLAG = 'Y') recspec WHERE E.EVENT_ID = MV_R.EVENT_ID(+) AND E.EVENT_ID = MV_BDE.EVENT_ID(+) AND E.EVENT_ID = recspec.EVENT_ID(+) AND E.EVENT_ID = CLS.EVENT_ID(+) AND E.CLIENT_ID = C.CLIENT_ID AND E.CLIENT_ID = '1078'; After rewritting select e.event_id, EVENT_STATUS_CODE, EVENT_TYPE_CODE, c.client_code, trunc(DATE_EXTRACTED), trunc(DATE_SUBMITTED), trunc(CLS.DATE_RETURNED), trunc(DATE_TYPED), trunc(REJECT_DATE), SUM_BILLED "bill_ttl", SUM_PAID, SUM_AMOUNT "Recoveries", trunc(DATE_OF_INCIDENT), EU.USER_REAL_NAME, EU.LEVEL_B_CODE, EU.USER_REAL_NAME, EU.LEVEL_B_CODE, trunc(STAGE_CREATED_DATE), REJECT_CODE, ISO_ERROR FROM EVENT E, CLIENT C, MV_RECOVERYDET_EVENT_SUM MV_R, CLS_SEND CLS, MV_BILLDETAIL_EVENT_SUM MV_BDE, END_USER EU, EVENT_END_USER EEU WHERE E.EVENT_ID = MV_R.EVENT_ID(+) AND E.EVENT_ID = MV_BDE.EVENT_ID(+) --AND E.EVENT_ID = recspec.EVENT_ID(+) AND E.EVENT_ID = CLS.EVENT_ID(+) AND E.CLIENT_ID = C.CLIENT_ID AND EEU.END_USER_ID = EU.END_USER_ID AND EEU.EVENT_ID(+) = E.EVENT_ID AND OWNER_FLAG = 'Y' AND E.CLIENT_ID = '1078'; ?
PX stuff, it's just the 'pipes' oracle uses to divide your table into pieces and the pieces of transformation. You don't have much control that beyond doing Oracle use parallel queries or not. I guess that you can specify a degree, but this isn't your problem, anyway. But if you're curious, PX is mentioned here. http://docs.Oracle.com/CD/B12037_01/server.101/b10752/ex_plan.htm
Using index becomes a little more complicated with outer joins, because they return the rows that do not match the table conduct. If the index will be useful on the tables of conduct. It is possible to what I was looking to take advantage of the index because each row of the table is returned to the outer join. If you want to limit who then you need some sort of filter condition and an index on that column filter would be useful.
Published by: watch on 2 may 2012 17:20
-
Rewrite the query with joins, and group by
Hello
It's an interview question.
Table names: bookshelf_checkout
virtual library
And the join condition between these two tables is title
We need to rewrite under request without using the join condition and group by clause?
When I was in College, I read most of SELECT statements can be replaced by operations base SQL (DEFINE the OPERATORS). Now, I am rewriting the query with SET operators, but not able to get the exact result.SELECT b.title,max(bc.returned_date - bc.checkout_date) "Most Days Out" FROM bookshelf_checkout bc,bookshelf b WHERE bc.title(+)=b.title GROUP BY b.title;
Kindly help me on this.
Thank you
SuriSomething like that?
1 WITH books AS ( 2 SELECT 'title 1' title FROM dual UNION ALL 3 SELECT 'title 2' FROM dual UNION ALL 4 SELECT 'title 3' FROM dual ), 5 bookshelf AS ( 6 SELECT 'title 1' title, DATE '2012-05-01' checkout_date, DATE '2012-05-15' returned_date FROM dual UNION ALL 7 SELECT 'title 1' title, DATE '2012-05-16' checkout_date, DATE '2012-05-20' returned_date FROM dual UNION ALL 8 SELECT 'title 2' title, DATE '2012-04-01' checkout_date, DATE '2012-05-15' returned_date FROM dual ) 9 SELECT bs.title, MAX(bs.returned_date - bs.checkout_date) OVER (PARTITION BY title) FROM bookshelf bs 10 UNION 11 (SELECT b.title, NULL FROM books b 12 MINUS 13* SELECT bs.title, NULL FROM bookshelf bs) SQL> / TITLE MAX(BS.RETURNED_DATE-BS.CHECKOUT_DATE)OVER(PARTITIONBYTITLE) ------- ------------------------------------------------------------ title 1 14 title 2 44 title 3
Lukasz
-
How can rewrite the query statement effectively
Hi gurus,
BANNER
----------------------------------------------------------------
Oracle Database 10g Release 10.2.0.4.0 - Production 64-bit
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
AMT for Linux: release 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
Table scripts
CREATE TABLE WAREHOUSE
(
IDZONE VARCHAR2 (6 BYTE) NOT NULL,
ZONE_CREATEDATE DATE NOT NULL,
DATE OF DT_WAREHOUSE,
DATE OF DT_POSTING
)
AREA ID, ZONE_CREATEDATE is PK
CREATE TABLE ZONE_VIEW
(
IDZONE VARCHAR2 (6 BYTE) NOT NULL,
ZONE_CREATEDATE DATE NOT NULL,
ZONE_NUM NUMBER (2) NOT NULL,
DATE OF TRANX_DATE
)
ID of the AREA, ZONE_CREATEDATE, ZONE_NUM is PK
Query
SELECT ID area, zone_createdate
Of
(
SELECT ID area, zone_createdate,
MAX (CASE WHEN zone_num = 18 AND tranx_date 'n' IS NOT NULL, THEN 1 TIME zone_num = 18 AND tranx_date IS NULL THEN 0 ELSE-1 END) region_18,.
MAX (CASE WHEN zone_num = 110 AND not IS NOT NULL, THEN 1 TIME = 110 zone_num tranx_date AND tranx_date IS NULL THEN 0 ELSE-1 END) region_110,.
MAX (CASE WHEN zone_num = 135 AND tranx_date no IS NOT NULL, THEN 1 TIMES zone_num = 135 AND tranx_date IS NULL THEN 0 ELSE-1 END) region_135,.
MAX (CASE WHEN zone_num = 140 AND tranx_date 'n' IS NOT NULL, THEN 1 TIME zone_num = 140 AND tranx_date IS NULL THEN 0 ELSE-1 END) region_140
OF zone_view
GROUP BY IDZone, zone_createdate
) zrn
WHERE zrn.region_18 <>0
AND (((zrn.region_110 = 1) OR (zrn.region_110 = - 1)) AND (there IS NOT (SELECT null from warehouse w WHERE w.zoneid = zrn.zoneid AND w.zone_createdate = zrn.zone_createdate AND w.dt_warehouse IS NULL)))
AND (((zrn.region_135 = 1) AND (there IS NOT (SELECT null from warehouse w WHERE w.zoneid = zrn.zoneid AND w.zone_createdate = zrn.zone_createdate AND w.dt_posting IS NULL))) OR (zrn.region_140 = 1))
OR ((zrn.region_18 >-1) AND (zrn.region_135 = - 1) AND (zrn.region_140 < 1))
OR ((zrn.region_110 = 1) AND (zrn.region_135 = - 1) AND (zrn.region_140, <>, 0))
);
Top query runs too slowly on the real data set. Is there an effective way to rewrite the query which can perform the dough?
Any help or suggestion would be appreciated
Thanks in advance
At the time where the application may not throw anything until after he has retrieved and grouped all the ranks of zone_view. His estimate of 7.5 minutes to scan millions 639 lines really fast enough - it's 85 million lines per minute.
This seems to be where the time went. The only way that the query can be accelerated is to recover some of the conditions that must be applied before the grouping. The only obvious possibilities for this are
(a) filter values of zone_num
(b) move the audit only
NOT EXISTS (SELECT null from warehouse w WHERE w.zoneid = zrn.zoneid AND w.zone_createdate = zrn.zone_createdate AND w.dt_warehouse IS NULL)
within the group, because this condition is applied regardless of the values in calculated fields. The AREA ID, ZONE_CREATEDATE are not null, so I suggest to try:
SELECT ID area, zone_createdate
Of
(
SELECT ID area, zone_createdate,
MAX (CASE WHEN zone_num = 18 AND tranx_date 'n' IS NOT NULL, THEN 1 TIME zone_num = 18 AND tranx_date IS NULL THEN 0 ELSE-1 END) region_18,.
MAX (CASE WHEN zone_num = 110 AND not IS NOT NULL, THEN 1 TIME = 110 zone_num tranx_date AND tranx_date IS NULL THEN 0 ELSE-1 END) region_110,.
MAX (CASE WHEN zone_num = 135 AND tranx_date no IS NOT NULL, THEN 1 TIMES zone_num = 135 AND tranx_date IS NULL THEN 0 ELSE-1 END) region_135,.
MAX (CASE WHEN zone_num = 140 AND tranx_date 'n' IS NOT NULL, THEN 1 TIME zone_num = 140 AND tranx_date IS NULL THEN 0 ELSE-1 END) region_140
OF zone_view
where (IDZone, zone_createdate) NOT IN (select the zone ID, w warehouse zone_createdate WHERE w.dt_warehouse IS NULL)
and zone_num (18, 110, 135, 140)
GROUP BY IDZone, zone_createdate
) zrn
WHERE zrn.region_18 <> 0
AND ((zrn.region_110 = 1) OR (zrn.region_110 = - 1))
AND (((zrn.region_135 = 1) AND (there IS NOT (SELECT null from warehouse w WHERE w.zoneid = zrn.zoneid AND w.zone_createdate = zrn.zone_createdate AND w.dt_posting IS NULL))) OR (zrn.region_140 = 1))
OR ((zrn.region_18 >-1) AND (zrn.region_135 = - 1) AND (zrn.region_140)<>
OR ((zrn.region_110 = 1) AND (zrn.region_135 = - 1) AND (zrn.region_140 <> 0))
)
Unfortunately, if the plan of the query time estimates are correct, most of the duration of the query is spent doing a reading zone_view in a full analysis, and which will not be changed by this query.
If there are many rows for each (IDZone, zone_createdate) zone_view pair, then it is possible that an index on (area ID, zone_num, zone_createdate) would contribute to this request, especially if most (IDZone, zone_createdate) pairs are filtered with the NOT IN (select the zone ID, zone_createdate w warehouse WHERE w.dt_warehouse IS NULL). More radical but probably effective measure would be a functional on index
zone_view (zone_num, IDZone, zone_createdate, case when tranx_date is null then 0 otherwise 1 end)
and using the expression in the query box:
SELECT ID area, zone_createdate
Of
(
SELECT ID area, zone_createdate,
NVL (MAX (CASE WHEN zone_num = 18 then case when tranx_date is null, then 0 or 1 end end),-1) region_18,.
NVL (MAX (CASE WHEN zone_num = 110 then case when tranx_date is null, then 0 or 1 end end),-1) region_110,.
NVL (MAX (CASE WHEN zone_num = 135 then case when tranx_date is null, then 0 or 1 end end),-1) region_135,.
NVL (MAX (CASE WHEN zone_num = 140 then case when tranx_date is null, then 0 or 1 end end),-1) region_140
OF zone_view
where (IDZone, zone_createdate) NOT IN (select the zone ID, w warehouse zone_createdate WHERE w.dt_warehouse IS NULL)
and zone_num (18, 110, 135, 140)
GROUP BY IDZone, zone_createdate
) zrn
WHERE zrn.region_18 <> 0
AND ((zrn.region_110 = 1) OR (zrn.region_110 = - 1))
AND (((zrn.region_135 = 1) AND (there IS NOT (SELECT null from warehouse w WHERE w.zoneid = zrn.zoneid AND w.zone_createdate = zrn.zone_createdate AND w.dt_posting IS NULL))) OR (zrn.region_140 = 1))
OR ((zrn.region_18 >-1) AND (zrn.region_135 = - 1) AND (zrn.region_140)<>
OR ((zrn.region_110 = 1) AND (zrn.region_135 = - 1) AND (zrn.region_140 <> 0))
)
This gives a very different plan on my database, by performing an iteration on relevant areas of performance status:
---------------------------------------------------------
| ID | Operation | Name |
---------------------------------------------------------
| 0 | SELECT STATEMENT | |
|* 1 | FILTER | |
| 2. VIEW | |
|* 3 | FILTER | |
| 4. HASH GROUP BY. |
| 5. ANTI NESTED LOOPS. |
| 6. INLIST ITERATOR. |
|* 7 | INDEX RANGE SCAN | ZV_F1 |
|* 8 | TABLE ACCESS BY INDEX ROWID | WAREHOUSE |
|* 9 | INDEX UNIQUE SCAN | WAREHOUSE_PK |
| * 10 | TABLE ACCESS BY INDEX ROWID | WAREHOUSE |
| * 11 | INDEX UNIQUE SCAN | WAREHOUSE_PK |
---------------------------------------------------------
Your plan will be different because you have data volumes (I didn't create millions of lines of test data)
It would be useful to know how many rows there are in the WAREHOUSE, how many distinct (IDZone, zone_createdate) pairs there are in zone_view and the number of rows actually returns the query, and how much is NOT IN (select the zone ID, w zone_createdate warehouse WHERE w.dt_warehouse IS NULL) because these relative numbers determine how these approaches are.
If there is a table containing all of the (area ID, zone_createdate) pairs which could take place in zone_view, which would have may another possible approach:
First filter possible pairs against NOT IN (select the zone ID, w warehouse zone_createdate WHERE w.dt_warehouse IS NULL)
Then attach them to the zone_view to retrieve only the rows in the filtered (IDZone, zone_createdate) pairs.
Good luck.
-
Rewrite the query, select below or try to get the necessary O/P
Hello..
My example of data.,.
Create table customer (name varchar2 (10), telephone1 telephone2 number (10), number of phone3 (10), (10) number, bitwisephone number (10));
Insert into customer values('a',23456,67890,null,12345);
Insert into customer values ('b', 67459,89760,null, 37689);
create table do_not_call (dont_call number (10));
insert into do_not_call values (67890);
insert into do_not_call values (37689);
Question: -.
--------------
Customer 'a' has value of numbers1 as 23456.check if telephone1 exists in the do_not_call table.
In fact there is no, so set the bit for numbers1 as "o" like wise search telephone2
& phone3.after update of the bitwisephone for each client should be as the output below.
Need to O/P: -.
-------------------
name bitwisephone
a 010
b 001
For that matter... I use "any" operator...
SELECT name, case when numbers1 = all (SELECT dont_call FROM do_not_call) and then put an end to '1' other '0'.
-case when telephone2 = all (SELECT dont_call FROM do_not_call) and then put an end to '1' other '0'.
-case when phone3 = all (SELECT dont_call FROM do_not_call) then '1' other '0' end 'Bits '.
OF THE customer;
Is there any other way to get the necessary O/P?
Thank you!!
Kind regards
VijayRajaram.Looks like one already answered Re: rewrite the query, select below or try to get the necessary O/P
with customer(name,phone1,phone2,phone3,bitwisephone) as (select 'a',23456,67890,12345,null from dual union all select 'b',67459,89760,37689,null from dual ), do_not_call(dont_call) as (select 67890 from dual union all select 23456 from dual union all select 37689 from dual ) select name, to_char(mod(trunc(sum(weight)/4),2))|| to_char(mod(trunc(sum(weight)/2),2))|| to_char(mod(sum(weight),2)) bitwisephone from (select name,phone1 phone,4 weight from customer union all select name,phone2,2 from customer union all select name,phone3,1 from customer ) c, do_not_call d where c.phone = d.dont_call(+) and d.dont_call is not null group by name
Please do not duplicate messages
Concerning
Etbin
-
Hello
I have a standard report oracle question which i've drawn from the data model
is it possible to rewrite this query without the bind variable, also the data provided as output is appropriate even when rewritten
WHT does & C_vendor_dynamic_SQL stand
thanking in advanceSELECT /*+ ORDERED_PREDICATES */ DISTINCT (v.vendor_id) C_vendor_id, v.vendor_name C_vendor_name, DECODE(:SORT_BY_ALTERNATE, 'Y', UPPER(v.vendor_name_alt), UPPER(v.vendor_name)) C_sort_vendor_name, v.segment1 C_vendor_num FROM ap_invoices i, po_vendors v WHERE 0 < (SELECT SUM(nvl(prepay_amount_remaining,amount)) FROM ap_invoice_distributions aid WHERE aid.invoice_id = i.invoice_id AND aid.line_type_lookup_code IN ('ITEM','TAX') AND nvl(aid.reversal_flag,'N') <> 'Y') AND v.vendor_id = i.vendor_id AND i.invoice_type_lookup_code = 'PREPAYMENT' AND i.cancelled_date IS NULL &C_vendor_dynamic_SQL ORDER BY DECODE(:SORT_BY_ALTERNATE, 'Y', UPPER(v.vendor_name_alt), UPPER(v.vendor_name))
Published by: makdutakdu on June 21, 2010 10:54I guess then this fine shud work, so was that, in the cud of user earlier request, give then here with the two bind and lexical values ignored the user cannot enter, but even of output?
Yes, the output will be the same.
The user can always have enter the values if you have not deleted the user settings, but even if the user enters the values the report output will be same each time. -
How export (unload) result of the query without running query on sql developer
Hello
I want to know how export (unload) result of the query without running query on sql developer.
I know this way.
1. execution of query
2. click on "Download" on the results tab
http://i.stack.imgur.com/CQ4Qb.jpg
Is he available unload a query result before the race?No, but you can do this ask the developer SQL change however, for other users can vote and add weight to the possible future implementation.
Kind regards
K. -
Query based ViewObject does pull not all attributes, when the query has 'WITH' clause
Hello
12.1.2 and 12.1.3 JDeveloper
When we try to create a custom query based ViewObject, and the query clause of "with."
So not all the columns selected in the query are appearing as attributes of the View object in the wizard.
This is the query. And it performs very well in Toad.
WITH dept_count AS)
SELECT department_id, COUNT (*) AS dept_count
Employees
GROUP BY department_id)
SELECT e.first_name AS employee_name,
DC1.dept_count AS emp_dept_count,
m.first_name AS manager_name,
DC2.dept_count AS mgr_dept_count
E employees,
dept_count dc1,
m employees,
dept_count dc2
WHERE e.department_id = dc1.department_id
AND e.manager_id = m.employee_id
AND m.department_id = dc2.department_id;
Only the EmployeeName attribute is extracted from the query. It does not show the rest of the attributes in the VO Wizard.
(I also tried to create a VO from the EntityObject class and make it editable as false, even in this case all attributes are not displayed.)
I was wondering if something changed in 12 c?
It works in 11.1.1.7
(A friend of mine just asked me this).
Thanks for any help.
Sameer
Jdev dislikes the syntax
You can rewrite as
SELECT e.first_name AS employee_name,
DC1.dept_count AS emp_dept_count,
m.first_name AS manager_name,
DC2.dept_count AS mgr_dept_count
E employees,
(
SELECT department_id, COUNT (*) AS dept_count
Employees
GROUP BY department_id) dc1,.
m employees,
(
SELECT department_id, COUNT (*) AS dept_count
Employees
GROUP BY department_id) dc2
WHERE e.department_id = dc1.department_id
AND e.manager_id = m.employee_id
AND m.department_id = dc2.department_id
who must work and give you the same result.
Timo
-
compose the query without using the query designer
New on this BEEP 10.1.3.4.1 product,
questions
1. is there a way to compose a query without using query builder but still has a way to see the result of the query under the PIF?
2. How is - a to compose a query prompt? I know that I can create parm after you create the data set, but at the stage of all data already call you query prompt as where employee id =? E_ID? or just not where clause
Sorry if these questions are too rudimentary, but I did not see that what we have answered according to the user's guide.
Thank you.
WANWhen you select the 'View' link, you should be able to see this option.
-
Rewrite the query to improve the performance and the optimized below cost.
Oracle 10g.
----------------------
Query
UPDATE FACETS_CUSTOM. MMR_DTL
SET
CAPITN_PRCS_IND = 2,
FIL_RUN_DT = Current_fil_run_dt,
ROW_UPDT_DT = dta_cltn_end_dttm
WHERE CAPITN_PRCS_IND = 5
AND HSPC_IND = 'Y '.
AND EXISTS (SELECT 1
OF FACETS_STAGE. CRME_FUND_DTL_STG STG_CRME
WHERE STG_CRME. MBR_CK = MMR_DTL. MBRSHP_CK
AND MMR_DTL. PMT_MSA_STRT_DT BETWEEN STG_CRME. ERN_FROM_DT AND STG_CRME. ERN_THRU_DT
AND STG_CRME. FUND_ID IN ('AAB1', '1AA2', '1BA2', 'AAB2', '1AA3', '1BA3', ' 1 B 80 ', ' 1 HAS 80 '))
AND EXISTS (SELECT 1
OF FACETS_CUSTOM. FCTS_TMS_MBRID_XWLK XWLK
WHERE XWLK. MBR_CK = MMR_DTL. MBRSHP_CK
AND MMR_DTL. PMT_MSA_STRT_DT BETWEEN XWLK. HSPC_EVNT_EFF_DT AND XWLK. HSPC_EVNT_TERM_DT);
Explain the plan of the query
-----------------------------------------------
Hash value of plan: 3109991485
-------------------------------------------------------------------------------------------------------
| ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
-------------------------------------------------------------------------------------------------------
| 0 | UPDATE STATEMENT. | 1. 148. 12431 (2) | 00:02:30 |
| 1. UPDATE | MMR_DTL | | | | |
| 2. SEMI NESTED LOOPS. | 1. 148. 12431 (2) | 00:02:30 |
|* 3 | HASH JOIN RIGHT SEMI | | 49. 5488. 12375 (2) | 00:02:29 |
| 4. TABLE ACCESS FULL | FCTS_TMS_MBRID_XWLK | 6494 | 64940 | 24 (0) | 00:00:01 |
|* 5 | TABLE ACCESS FULL | MMR_DTL | 304K | 29 M | 12347 (2) | 00:02:29 |
|* 6 | TABLE ACCESS BY INDEX ROWID | CRME_FUND_DTL_STG | 1. 36. 5 (0) | 00:00:01 |
|* 7 | INDEX RANGE SCAN | IE1_CRME_FUND_DTL_STG | 8. | 1 (0) | 00:00:01 |
-------------------------------------------------------------------------------------------------------
Information of predicates (identified by the operation identity card):
---------------------------------------------------
3 - access("XWLK".") MBR_CK "=" MMR_DTL. " ("' MBRSHP_CK")
filter ("XWLK". "HSPC_EVNT_EFF_DT" < = INTERNAL_FUNCTION ("MMR_DTL". " PMT_MSA_STRT_DT') AND
'XWLK '. "" HSPC_EVNT_TERM_DT "> = INTERNAL_FUNCTION ("MMR_DTL". "PMT_MSA_STRT_DT")) "
5 - filter("CAPITN_PRCS_IND"=5 AND "HSPC_IND"='Y')
6 filter (("STG_CRME". "FUND_ID" = "1 HAS 80 ' OR 'STG_CRME'." " FUND_ID "="1AA2"OR"
'STG_CRME '. "FUND_ID"= '1AA3' OR 'STG_CRME'. "FUND_ID" = "1 B 80 ' OR 'STG_CRME'. '. "FUND_ID" = "1BA2" OR "
'STG_CRME '. "FUND_ID"= "1BA3" OR "STG_CRME". "FUND_ID"= "AAB1" OR "STG_CRME". ("FUND_ID"="AAB2") AND
'STG_CRME '. "" ERN_FROM_DT "< = INTERNAL_FUNCTION ("MMR_DTL". "PMT_MSA_STRT_DT") AND "
'STG_CRME '. "" ERN_THRU_DT "> = INTERNAL_FUNCTION ("MMR_DTL". "PMT_MSA_STRT_DT")) "
7 - access("STG_CRME".") MBR_CK "=" MMR_DTL. " ("' MBRSHP_CK")
I could not optimize this query for best performance and optimized the cost... Can someone guide me on this.
Thank you
DS
You think you're going to lines updates 85K, Oracle think it will update a line.
At the time where the existence of the first test runs that oracle think already up to 49 lines, which is probably why he uses the loop join nested for the second test. (In your version of Oracle, the subquery introduced existence a very bad assumption (small) on the amount of data will survive).
It is possible that you will get better performance if you hint Oracle using a hash join for testing the existence - and you might want to think what test will eliminate most of the data and that we can first force.
Having said that, however, note that MMR_DTL research is a considerable fraction of the cost of the query - and an analysis is an easy thing for Oracle cost properly - if, despite your comments on update a column with a clue to this topic, you will find that the query can be more effective if you use an index. This is more likely to be the case if data ' WHERE CAPITN_PRCS_IND = 5 AND HSPC_IND = 'Y' "is well grouped (perhaps the latest data added to the table).". " You could then reduce the cost of maintaining this index by creating an index based on a feature that indexes only the lines where the predicate are both true so that the 2 update deletes the index entries and allows the index remain as thin as possible.
Concerning
Jonathan Lewis
-
Hello
Can anyone suggest an idea to rewrite this query? This query takes longer than expected, probably
they way the application is made is not fair? Thanks in advance! I use 11g
SELECT brand_id, region_id, sku_base_id, desc_key, (SELECT MAX (cps.product_code) FROM cat_prod_sku_vw cps WHERE cps.brand_id = srl.brand_id AND cps.region_id = srl.region_id AND cps.brand_id = 4 AND cps.region_id = 0 AND ( cps.parent_cat_id || 'PROD' || cps.prod_base_id) = srl.desc_text) AS desc_text FROM sku_rgn_lang_vw srl WHERE brand_id = 4 AND region_id = 0 AND desc_key LIKE 'www_pcode_%' AND LENGTH (desc_text) > 6 AND desc_text LIKE 'CAT%' ;
You should look at this thread {message identifier: = 9360003} to get an idea of what other information is required.
However, I'd be inclined to re - write as an (external) join instead of a scalar select statement. Something more like:
SELECT srl.brand_id, srl.region_id, srl.sku_base_id, srl.desc_key, cps.desc_text FROM sku_rgn_lang_vw srl left join (SELECT brand_id, region_id, parent_cat_id||'PROD'||prod_base_id desc_text MAX (product_code) product_code FROM cat_prod_sku_vw cps WHERE brand_id = 4 AND region_id = 0 GROUP BY brand_id, region_id, parent_cat_id||'PROD'||prod_base_id) cps on cps.brand_id = srl.brand_id AND cps.region_id = srl.region_id AND cps.parent_cat_id||'PROD'||cps.prod_base_id = srl.desc_text WHERE srl.brand_id = 4 AND srl.region_id = 0 AND srl.desc_key LIKE 'www_pcode_%' AND LENGTH (cps.desc_text) > 6 AND cps.desc_text LIKE 'CAT%' ;
Although I'm not entirely sure, I had all the correct alias.
John
-
I need assistance of query SQL, a query to get the same without union clause
EmpNo, ename sum (sal) sum (deptno)
200-2000-10 Tom
201 3000 10 smith
Alfred 202 20 3000
40 8000 totalselect NVL(TO_CHAR(employee_id), 'Total'), max(last_name), sum(salary), sum(department_id) from employees group by rollup(employee_id), ()
-
Get the columns returned by the query without running
I have a table that stores SELECT queries in a column. I developed a .net application where the interesting thing for the user is what columns of the following SELECT statement returns. Currently, I load the sql as an OracleCommand object CommandText and fill a DataTable using an OracleDataAdapter object. I then read the names of the columns of the table filled. The data is not fully used. Requests can take up to 15 seconds to run. Because I do not used the data, I was hoping to eliminate the actual recovery of data and reduce the time needed to retrieve the records. Is it possible to analyze the statement for the colunm names with it makes the request for enforcement? Thank you.I imagine that there is a way you can search in the data dictionary, but you can also try to add 'WHERE 1 = 0' If you want the metadata.
It will be useful,
Greg -
How to rewrite the sql statement?
Hello my query goes like this:
Select a, b, c
from (select 5A, b null, null double c
Union of all the
Select null, 4, the double null
Union of all the
Select 10, 3, double null) test_tab;
and I want to get the result
5 null null
null null 4
10 null null
3 null null
How can I rewrite the query without changing the structure of a table?
Kind regards
IgorHello
A way
select a, null b, null c from test_tab where a is not null union all select null, b, null from test_tab where b is not null union all select null, null, c from test_tab where c is not null
Concerning
Anurag
Maybe you are looking for
-
I was able to access LinkedIn yesterday. Today the Linked In says "connecting" (she revolves) of Safari or Firefox (mac computer with current operating system). I am able to access the Linked In to my iphone. I deleted the cookies, cache, history, re
-
workflow - several videos of a multicam
I'm trying to help a local church with their media. I would really appreciate help in the best way to create several videos of a single clip multicam. I import everything from two or three cameras and two recorders audio non - cam, and then create a
-
Satellite P300 - 219 PSPCCE - what should be the optimal heat of CPU?
Hello there; I use for my laptop Satellite P300-219 (PSPCCE) newly bought about a week now. When you type I can't help noticing, the place where I put my left hand, I want to say the empty space to the left of the touchpad, feels much too hot. I look
-
Windows Media Player and Windows Photo Gallery
1. photo library videos play with green screen jumping in and out of the video - when I record the same video on a disc plays OK.2. when I rip music in Windows Media Player, it plays back jerky. Help and don't forget I'm a novice in computer science.
-
Diagnostic report (1.9.0019.0):-----------------------------------------Given WGA-->Validation status: invalid licenseValidation code: 50 Code of Validation caching: 0x0Windows product key: *-* - GJY49 - VJBQ7-HYRR2Windows product key hash: W5/6nm6F2