Query tuning for search within blob content.
Hi,
I ve got a query which searches across 3 tables. When I include a search condition : (CONTAINS(CF.blob_content,''{''||:P146_TEXT||''}'',1)>0 AND CF.REF_ID = CR.REF_ID) the query takes really long time to execute. Is there a way to reduce the execution time. If you need any more info on this, please let me know. I need to work out a solution for this issue really soon.
I have indexed the blob_content column using a domain index type.
Thanks,
Vignesh
Hi,
an explain plan would be helpful.
Is it possible to use the bind variable already include the "{", i mean :P146_TEXT := '{'||:P146_TEXT||'}' and then use :p146_text solely in the contains. Then you are using a real bind variabel. Maybe a second variable is necessary to make it work.
Another possibility is that CF.REF_ID is not indexed or CR.REF_ID is not indexed, that's way it's handy to give an explain plan. Then you can see maybe the problem.
Herald ten Dam
Superconsult.nl
Similar Messages
-
Query tuning for data-warehousing application in Oracle 8i.
We have to pick up 24 months old data. Each month data is kept in a different partition.
2007-May month data is kept in PRESC200705 partition
SELECT r.account_id,
p.presc_num,
spm.product_id,
p.month,
t.best_call_state,
sum(p.trx_count)
FROM rlup_assigned_account r,
temp_presc_num_TEST t,
retail.prescrip_retail partition (PRESC200705) p,
sherlock.sherlock_product_mapping spm
WHERE spm.product_id like '056%'
and spm.mds6 = p.product_id
and t.CLIENT_ID = p.presc_num
and r.ndc_pyr_id = p.payer_plan
and t.best_call_state = r.ST
GROUP BY r.account_id,
p.presc_num,
spm.product_id,
p.month,
t.best_call_state
Q This Query is to be tuned
SQL> SELECT table_name,
2 partition_name,
3 high_value,
4 num_rows
5 FROM user_tab_partitions
6 ;
no rows selectedI have the following task:
Requirement:
According to the client, new partitions are created every month.
So the query should contain only the 24 most recent partions leaving one old partition every month.
So, the query becomes dynamic.
The query will have to leave one old partion every month and move ahead with the new partion created.
The total partitions accessed should not cross 24.
Is this possible?
Partition# for OCt 2007
1
2
3
4
5
6
7
24
Partition# for Nov 2007
Old|New
1
2..1
3..2
4..3
5..4
6..5
7..6
24..23
..24
Secondly, with one month data (in a partitioned table), the query takes about one hour to run.
with 24 month data accessed by the query, the query will take 24 hours to run.
I am sure that Oracle can be tuned to run on such huge data with ease and the query output can
come within seconds.. Otherwise, nobody would use oracle for datawarehousing applicaions.
Q. How do I write a dynamic query that references 24 recent partitions, using the query provided:
abc>SELECT r.account_id,
2 p.presc_num,
3 spm.product_id,
4 p.month,
5 t.best_call_state,
6 sum(p.trx_count)
7 FROM rlup_assigned_account r,
8 temp_presc_num_TEST t,
9 retail.prescrip_retail partition (PRESC200705) p,
10 sherlock.sherlock_product_mapping spm
11 WHERE spm.product_id like '056%'
12 and t.CLIENT_ID='934759'
13 and spm.mds6 = p.product_id
14 and t.CLIENT_ID = p.presc_num
15 and r.ndc_pyr_id = p.payer_plan
16 and t.best_call_state = r.ST
17 GROUP BY r.account_id,
18 p.presc_num,
19 spm.product_id,
20 p.month,
21 t.best_call_state
22 ;
retail.prescrip_retail partition (PRESC200705) p,
Partition name, PRESC200705 cannot be hardcoded into the sql.
Sql should take a range of 24 recent partitions.
And the query should execute fast too.
Now, is that what is called a challenge?
+++++++++++++++++++++++++++++++++++++++++++++++
Here are the index/constraints/explain_plan output on prescrip_retail table (which is partitioned)
as well as other tables to which prescrip_retail table is joined
This is what prescrip_retail looks like. This is the table having partitions.
It does not seem to have a primary key!
SQL> desc prescrip_retail
Name Null? Type
PRESC_NUM NUMBER
PFIER_NUM CHAR(8)
RELID NOT NULL CHAR(9)
ME_NUM NOT NULL CHAR(10)
PRODUCT_ID NOT NULL CHAR(6)
PRODUCT_FRMSTR NOT NULL CHAR(1)
PAYER_PLAN NOT NULL CHAR(6)
MONTH NOT NULL DATE
PYMT_CODE NOT NULL CHAR(1)
NRX_COUNT NOT NULL NUMBER(7)
NRX_QUANTITY NOT NULL NUMBER(9)
NRX_DOLLARS NOT NULL NUMBER(13,2)
TRX_COUNT NOT NULL NUMBER(7)
TRX_QUANTITY NOT NULL NUMBER(9)
TRX_DOLLARS NOT NULL NUMBER(13,2)
Table Size of Prescrip_Retail...
1 select table_name,tablespace_name,pct_free,pct_used,num_rows,avg_space
2 from all_tables
3* where table_name='PRESCRIP_RETAIL'
SQL> /
TABLE_NAME TABLESPACE_NAME PCT_FREE PCT_USED NUM_ROWS AVG_SPACE
PRESCRIP_RETAIL 2806673860 360
Explain Plan for the query to be tuned...
22:32:31 SQL> explain plan set statement_id='vista_query'
22:43:33 2 for
22:43:35 3 SELECT r.pfier_account_id,
22:43:41 4 p.presc_num,
22:43:41 5 spm.product_id,
22:43:41 6 p.month,
22:43:41 7 t.best_call_state,
22:43:41 8 sum(p.trx_count)
22:43:41 9 FROM rlup_assigned_account r,
22:43:41 10 temp_presc_num_TEST t,
22:43:41 11 retail.prescrip_retail partition (PRESC200705) p,
22:43:41 12 sherlock.sherlock_product_mapping spm
22:43:41 13 WHERE spm.product_id like '056%'
22:43:41 14 and spm.mds6 = p.product_id
22:43:41 15 and t.CLIENT_ID = p.presc_num
22:43:41 16 and r.ndc_pyr_id = p.payer_plan
22:43:41 17 and t.best_call_state = r.ST
22:43:41 18 GROUP BY r.pfier_account_id,
22:43:41 19 p.presc_num,
22:43:41 20 spm.product_id,
22:43:41 21 p.month,
22:43:41 22 t.best_call_state;
Explained.
SQL> select statement_id,operation,options,object_name
2 from plan_table
3 where statement_id='vista_query';
22:46:03 SQL> /
STATEMENT_ID OPERATION OPTIONS OBJECT_NAME
vista_query SELECT STATEMENT
vista_query SORT GROUP BY
vista_query HASH JOIN
vista_query TABLE ACCESS FULL TEMP_PRESC_NUM_TEST
vista_query HASH JOIN
vista_query TABLE ACCESS FULL RLUP_ASSIGNED_ACCOUNT
vista_query HASH JOIN
vista_query TABLE ACCESS FULL SHERLOCK_PRODUCT_MAPPING
vista_query TABLE ACCESS FULL PRESCRIP_RETAIL
9 rows selected.
Partition Pruning: This is supposed to provide an insight to the partitions oracle
vists internally...
I guess we can use "month>= add_months(sysdate,-24)" instead of partions too.
I don't think Oracle is visiting any partitions.
I'll also search into all_tab_partitions to verify this.
Explain_Plan for what partitions oracle visits internally (partition pruning):
SQL> ed
Wrote file afiedt.buf
1 explain plan set statement_id='vista'
2 for select * from retail.prescrip_retail
3* where month>= add_months(sysdate,-24)
SQL> /
Explained.
Elapsed: 00:00:00.05
22:13:56 SQL> select statement_id,operation,options,object_name
22:14:28 2 from plan_table
22:14:30 3 where statement_id='vista';
STATEMENT_ID OPERATION
OPTIONS OBJECT_NAME
vista SELECT STATEMENT
vista PARTITION RANGE
ITERATOR
vista TABLE ACCESS
FULL PRESCRIP_RETAIL
Elapsed: 00:00:01.00
Indexes/Constraints on PRESCRIP_RETAIL table:
SQL> ED
Wrote file afiedt.buf
1 SELECT TABLE_NAME,TABLE_TYPE,INDEX_NAME,INDEX_TYPE,PCT_FREE,STATUS,PARTITIONED
2 FROM ALL_INDEXES
3* WHERE TABLE_NAME IN ('PRESCRIP_RETAIL')
SQL> /
TABLE_NAME TABLE INDEX_NAME INDEX_TYPE PCT_FREE STATUS PAR
PRESCRIP_RETAIL TABLE BX6_PRESC_RELID BITMAP N/A YES
PRESCRIP_RETAIL TABLE BX7_PRESC_ME BITMAP N/A YES
PRESCRIP_RETAIL TABLE BX1_PRESC_PROD BITMAP N/A YES
PRESCRIP_RETAIL TABLE BX2_PRESC_PAYER BITMAP N/A YES
PRESCRIP_RETAIL TABLE BX3_PRESC_PAYERCD BITMAP N/A YES
PRESCRIP_RETAIL TABLE BX4_PRESC_PRESC BITMAP N/A YES
PRESCRIP_RETAIL TABLE BX5_PRESC_PFIER BITMAP N/A YES
7 rows selected.
SQL> ed
Wrote file afiedt.buf
1 SELECT TABLE_NAME,CONSTRAINT_NAME,CONSTRAINT_TYPE,STATUS,DEFERRABLE
2 FROM ALL_CONSTRAINTS
3* WHERE TABLE_NAME IN ('PRESCRIP_RETAIL')
SQL> /
TABLE_NAME CONSTRAINT_NAME C STATUS DEFERRABLE
PRESCRIP_RETAIL SYS_C001219 C ENABLED NOT DEFERRABLE
PRESCRIP_RETAIL SYS_C001220 C ENABLED NOT DEFERRABLE
PRESCRIP_RETAIL SYS_C001221 C ENABLED NOT DEFERRABLE
PRESCRIP_RETAIL SYS_C001222 C ENABLED NOT DEFERRABLE
PRESCRIP_RETAIL SYS_C001223 C ENABLED NOT DEFERRABLE
PRESCRIP_RETAIL SYS_C001224 C ENABLED NOT DEFERRABLE
PRESCRIP_RETAIL SYS_C001225 C ENABLED NOT DEFERRABLE
PRESCRIP_RETAIL SYS_C001226 C ENABLED NOT DEFERRABLE
PRESCRIP_RETAIL SYS_C001227 C ENABLED NOT DEFERRABLE
PRESCRIP_RETAIL SYS_C001228 C ENABLED NOT DEFERRABLE
PRESCRIP_RETAIL SYS_C001229 C ENABLED NOT DEFERRABLE
PRESCRIP_RETAIL SYS_C001230 C ENABLED NOT DEFERRABLE
PRESCRIP_RETAIL SYS_C001231 C ENABLED NOT DEFERRABLE
13 rows selected.
In all_tables:
NUM_ROWS:2806673860
AVG_SPACE:360
Here is the data size in the table.
SQL> select count(*) from PRESCRIP_RETAIL;
COUNT(*)
4602980312
Again, here is the partition information and the amount of data in each partition:
SQL> ed
Wrote file afiedt.buf
1 select
2 partition_name,SUBPARTITION_COUNT,PARTITION_POSITION,TABLESPACE_NAME,
3 NUM_ROWS
4 from all_tab_partitions
5 where table_name='PRESCRIP_RETAIL'
6* order by partition_name desc
SQL> /
PARTITION_NAME SUBPARTITION_COUNT PARTITION_POSITION TABLESPACE_NAME NUM_ROWS
PRESC200705 0 36 PRESC_PARTITION_29 141147085
PRESC200704 0 35 PRESC_PARTITION_28 140299317
PRESC200703 0 34 PRESC_PARTITION_27 140703128
PRESC200702 0 33 PRESC_PARTITION_26 132592733
PRESC200701 0 32 PRESC_PARTITION_25 145832356
PRESC200612 0 31 PRESC_PARTITION_24 136702837
PRESC200611 0 30 PRESC_PARTITION_23 137421767
PRESC200610 0 29 PRESC_PARTITION_22 140836119
PRESC200609 0 28 PRESC_PARTITION_21 131273578
PRESC200608 0 27 PRESC_PARTITION_20 134967317
PRESC200607 0 26 PRESC_PARTITION_19 130785504
PRESC200606 0 25 PRESC_PARTITION_18 131472696
PRESC200605 0 24 PRESC_PARTITION_17 138590581
PRESC200604 0 23 PRESC_PARTITION_16 126849798
PRESC200603 0 22 PRESC_PARTITION_15 137164667
PRESC200602 0 21 PRESC_PARTITION_14 126938544
PRESC200601 0 20 PRESC_PARTITION_13 135408324
PRESC200512 0 19 PRESC_PARTITION_12 123285100
PRESC200511 0 18 PRESC_PARTITION_11 121245764
PRESC200510 0 17 PRESC_PARTITION_10 122112932
PRESC200509 0 16 PRESC_PARTITION_09 119137399
PRESC200508 0 15 PRESC_PARTITION_08 123372311
PRESC200507 0 14 PRESC_PARTITION_07 112905435
PRESC200506 0 13 PRESC_PARTITION_06 119581406
PRESC200505 0 12 PRESC_PARTITION_05 123977315
PRESC200504 0 11 PRESC_PARTITION_04 118975597
PRESC200503 0 10 PRESC_PARTITION_03 125782688
PRESC200502 0 9 PRESC_PARTITION_02 117448839
PRESC200501 0 8 PRESC_PARTITION_01 122214436
PRESC200412 0 7 PRESC_PARTITION_36 124799998
PRESC200411 0 6 PRESC_PARTITION_35 125471042
PRESC200410 0 5 PRESC_PARTITION_34 118457422
PRESC200409 0 4 PRESC_PARTITION_33 119537488
PRESC200408 0 3 PRESC_PARTITION_32 121319137
PRESC200407 0 2 PRESC_PARTITION_31 115226621
PRESC200406 0 1 PRESC_PARTITION_30 119143031
36 rows selected.
Data in induvidual partition of PRESCRIP_RETAIL.
SQL> SELECT COUNT(*) FROM PRESCRIP_RETAIL PARTITION(PRESC200704);
COUNT(*)
140299317
SQL> SELECT COUNT(*) FROM PRESCRIP_RETAIL PARTITION(PRESC200703);
COUNT(*)
140703128
SQL> SELECT COUNT(*) FROM PRESCRIP_RETAIL PARTITION(PRESC200702);
COUNT(*)
132592733
SQL> SELECT COUNT(*) FROM PRESCRIP_RETAIL PARTITION(PRESC200701);
COUNT(*)
145832356
SQL> SELECT COUNT(*) FROM PRESCRIP_RETAIL PARTITION(PRESC200606);
COUNT(*)
131472696
SQL> SELECT COUNT(*) FROM PRESCRIP_RETAIL PARTITION(PRESC200605);
COUNT(*)
138590581
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other tables info:
Index of other tables related to PRESCRIP_REATIL:
SQL> SELECT TABLE_NAME,TABLE_TYPE,INDEX_NAME,INDEX_TYPE,PCT_FREE,STATUS,PARTITIONED
2 FROM ALL_INDEXES
3 WHERE TABLE_NAME IN ('RLUP_ASSIGNED_ACCOUNT','TEMP_PRESC_NUM_TEST','SHERLOCK_PRODUCT_MAPPING');
SQL> /
TABLE_NAME TABLE INDEX_NAME INDEX_TYPE PCT_FREE STATUS PAR
SHERLOCK_PRODUCT_MAPPING TABLE SHERLOCK_PRODUCT_MAPPING_PK NORMAL 10 VALID NO
SHERLOCK_PRODUCT_MAPPING TABLE SHERLOCK_PRODUCT_MAPPING_X1 NORMAL 0 VALID NO
SHERLOCK_PRODUCT_MAPPING TABLE SHERLOCK_PRODUCT_MAPPING_BX1 BITMAP 0 VALID NO
SHERLOCK_PRODUCT_MAPPING TABLE SHERLOCK_PRODUCT_MAPPING_BX2 BITMAP 0 VALID NO
SHERLOCK_PRODUCT_MAPPING TABLE SHERLOCK_PRODUCT_MAPPING_BX3 BITMAP 0 VALID NO
RLUP_ASSIGNED_ACCOUNT TABLE BX1_RLUP_ASSIGNED_ACCT_PYR BITMAP 10 VALID NO
RLUP_ASSIGNED_ACCOUNT TABLE BX2_RLUP_ASSIGNED_ACCT_TOPLVL BITMAP 10 VALID NO
RLUP_ASSIGNED_ACCOUNT TABLE BX3_RLUP_ASSIGNED_ACCT_PBM BITMAP 10 VALID NO
RLUP_ASSIGNED_ACCOUNT TABLE BX4_RLUP_ASSIGNED_ACCT_AA_FLAG BITMAP 10 VALID NO
RLUP_ASSIGNED_ACCOUNT TABLE BX5_RLUP_ASSIGNED_ACCT_AA_CHD BITMAP 10 VALID NO
RLUP_ASSIGNED_ACCOUNT TABLE BX6_RLUP_ASSIGNED_ACCT_PBM_FLG BITMAP 10 VALID NO
RLUP_ASSIGNED_ACCOUNT TABLE BX7_RLUP_ASSIGNED_ACCT_ACCTID BITMAP 10 VALID NO
RLUP_ASSIGNED_ACCOUNT TABLE PK_RLUP_ASSIGNED_ACCOUNT NORMAL 10 VALID NO
13 rows selected.
Constraints in other tables:
SQL> SELECT TABLE_NAME,CONSTRAINT_NAME,CONSTRAINT_TYPE,STATUS,DEFERRABLE
2 FROM ALL_CONSTRAINTS
3 WHERE TABLE_NAME IN ('RLUP_ASSIGNED_ACCOUNT','TEMP_PRESC_NUM_TEST','SHERLOCK_PRODUCT_MAPPING');
TABLE_NAME CONSTRAINT_NAME C STATUS DEFERRABLE
RLUP_ASSIGNED_ACCOUNT SYS_C00637753 C ENABLED NOT DEFERRABLE
RLUP_ASSIGNED_ACCOUNT SYS_C00637754 C ENABLED NOT DEFERRABLE
RLUP_ASSIGNED_ACCOUNT SYS_C00637755 C ENABLED NOT DEFERRABLE
RLUP_ASSIGNED_ACCOUNT SYS_C00637756 C ENABLED NOT DEFERRABLE
RLUP_ASSIGNED_ACCOUNT SYS_C00637757 C ENABLED NOT DEFERRABLE
RLUP_ASSIGNED_ACCOUNT SYS_C00637758 C ENABLED NOT DEFERRABLE
RLUP_ASSIGNED_ACCOUNT SYS_C00637759 C ENABLED NOT DEFERRABLE
RLUP_ASSIGNED_ACCOUNT SYS_C00637760 C ENABLED NOT DEFERRABLE
RLUP_ASSIGNED_ACCOUNT SYS_C00637761 C ENABLED NOT DEFERRABLE
RLUP_ASSIGNED_ACCOUNT SYS_C00637762 C ENABLED NOT DEFERRABLE
RLUP_ASSIGNED_ACCOUNT PK_RLUP_ASSIGNED_ACCOUNT P ENABLED NOT DEFERRABLE
TEMP_PRESC_NUM_TEST SYS_C00640536 C ENABLED NOT DEFERRABLE
12 rows selected.
TEMP_PRESC_NUM_TEST does not contain any constraints or index. -
SQL error for searches within Arch forums
Hi guys,
Since last night, when ever I try to run a search, whether it be a pre-defined search like New Posts or last 12h, or a keyword search within the search page, I get an error:
Could not delete old search id sessions
DEBUG MODE
SQL Error : 1016 Can't open file: 'phpbb_search_results.MYI' (errno: 145)
DELETE FROM phpbb_search_results WHERE session_id NOT IN ('b8a882a76bd524ca2cae00763907813a', 'ff63868080729e0ee81c83f1e2b08fac', '153ae6e2b7dfa3b1acab764caf6251a9', '61230f3df774fc9e05bbd91b9de8ab6a', 'ebea35cab271f97e47a0edeb867f350b', '852bae4b6e661b50c6e656eacab5204f', '874a6ac043dfb52bd2162d92f3700b28',
... (goes on for ages) ...
'eb520a66784db4079cf64fbf16316d65', '9f2f2ebe525f98222e32c1cefffd7ea1')
Line : 663
File : search.php
This is rather annoying as I can't look for the latest posts easily.There's already a discussion about it here:
http://bbs.archlinux.org/viewtopic.php?t=17004
Locking to keep continuity. -
Query tuning for query using connect by prior
I have written following query to fetch the data. The query is written in this format because there are multiple rows, which make one recrd and we need to bring that record into one row.
For one CAT(commented here), this query takes around 4 minutes and fetches 6900 records but when it runs for 3 CAT, it takes 17 mins.
I want to tune this as this has to run for 350 CAT values.
It is doing FTS on the main table. I tried to use different hints like PARALLEL, APPEND (in insert) but nothing worked.
The cost of the query is 51.
Any help/suggestions will be appreciated.
SELECT DISTINCT MIN(SEQ) SEQ,
PT, APP, IT, LR, QT,CD, M_A_FLAG,
STRAGG(REM) REM, -- aggregates the data from different columns to one which is parent
CAT
FROM (WITH R AS (SELECT CAT, SEQ, PT, M_A_FLAG, IT, LR,QT,CD, REM, APP
FROM table1
WHERE REC = '36' AND M_A_FLAG = '1'
--AND CAT = '11113')
SELECT CAT, SEQ,
CONNECT_BY_ROOT PT AS PT,
CONNECT_BY_ROOT APP AS APPL,
M_A_FLAG,
CONNECT_BY_ROOT IT AS IT,
CONNECT_BY_ROOT LR AS LR,
CONNECT_BY_ROOT QT AS QT,
CONNECT_BY_ROOT CD AS CD,
REM
FROM R A
START WITH PT IS NOT NULL
CONNECT BY PRIOR SEQ + 1 = SEQ
AND PRIOR CAT = CAT
AND PT IS NULL)
GROUP BY PT, APP, IT,LR, QT, CD, M_A_FLAG, CAT
ORDER BY SEQ;
Thanks.
Edited by: user2544469 on Feb 11, 2011 1:12 AMThe following threads detail the approach and information required.
Please gather relevant info and post back.
How to post a SQL tuning request - HOW TO: Post a SQL statement tuning request - template posting
When your query takes too long - When your query takes too long ... -
Fastest method for searching within a PDF file?
I have created a PDF document that holds all document reports for the last 10 years. It is currently 30,000 pages. As time goes on, incoming reports append to this PDF. This has proven to be an excellent way of holding and retrieving information, allowing me to pull up reports using specific search criteria.
The question I pose is this. Is there any faster way to search this mammoth document than the adobe search feature? The adobe search feature has great functionality, without a doubt. And even with 30,000 pages I can search the entire document in about 5 minutes or so, however in this day and age, 5 minutes can be a lifetime, especially to a client, lawyer, doctor, etc...
Does anyone know of a way of improving Adobe's search function to expedite it, or know of any existing third party programs that are able to do this (free or for cost)?
I appreciate your time, love the community, and await your response.
Have a great day.Hi,
You can try going to finder, hitting CMD + F and below search this mac, you should see kind. You can try switching that contents and the second option to documents.
Hope this helps,
Zevie -
SQL Query constructing for searching values in Tables single Column
I have Table USER_SERVICES with 2 Columns USER_NAME, Services. Please find below sample data on USER_SERVICES Table.
A user can be assigned with multiple services(service1, service2 etc.,). So we store data as below :
USER_NAME Services
user1 service1
user1 service2
user1 service3
user2 service1
user2 service2
user3 service3
user4 service4
I need to frame a SQL Query to 'select users assigned with Service A and Service B and Service n'.
Note: 'And' condition is used when Searching for multiple services.
Example: The SQL Query has to dynamically handle condition if i give Single Service, multiple Services(service1 and service2 e.t.c,)
If i say select users assigned with service1 and service2, from the above Table, result should be user1 and user2
If i say select users assigned with service1 and service2 and service3, from the above Table, result should be user1
If i say select users assigned with service4 from the above table, result should be user4
If i say select users assigned with service1 from the above table, result should be user2,user1
If i say select users assigned with service1 and service2 from the above table, result should be user2,user1
How do i construct the SQL Query. Any help will be appreciated.
Thanks,
Sathish
Alternate email: [email protected]How it will be stored? In a string or a table or a collection type?
If you have it in a table you can do like this.
with t
as
select 'user1' user_name, 'service1' services from dual union all
select 'user1', 'service2' from dual union all
select 'user1', 'service3' from dual union all
select 'user2', 'service1' from dual union all
select 'user2', 'service2' from dual union all
select 'user3', 'service3' from dual union all
select 'user4', 'service4' from dual
t1 as
select 'service1' services from dual union all
select 'service2' from dual
select distinct user_name
from (
select t.user_name, t.services, t1.services, count(t1.services) over(partition by t.user_name) cnt, t1.cnt cnt_1
from t
left join (select t1.*, count(*) over() cnt from t1) t1 on t1.services = t.services
where cnt = cnt_1 -
Sql query tuning for null columns
Hi All
I have one query which runs on a table X.
This table X has one column COL1 with 10 million rows.
Out of 10million rows, 4Million rows are null.
Btree Index is availabe on this column. No other type of index feasible.
I suspect that these null rows are causing burden over my query and is slowing response.
Is there any way i can improve performance for that query?
Any help will be appreciated.
Sun10
Oracle10G 10.2.0.3.0
Thanks
aps
Edited by: aps on Apr 3, 2009 9:44 AMAps,
YOu can generated explan plan from sqlplus like this
sqlplus username/password
Note: And if user is not set with plustrace then use sqlplus '/as sysdba' and qualify your tables with schemaname.table_name
sql>set timi on;
sql> set lines 400;
sql> set autotrace traceonly;
sql>select a.account_no,a.read_no,a.inc_obj from billadjmaster a,masterdata b
where a.account_no=b.acc_no
and
b.item_type=22
and b.idate>'23-mar-2009'
order by a.account_no,a.read_no;Regards -
Dear Experts,
Please find herewith below my code. The problem is with KONV table... This report is based on many conditions of KONV table... So the specific table has to be READ many times with all data. How can i Fine tune it... The report is taking a long time to execute... Any commands or way to optimise the report..
SELECT
vbeln_i
vkorg
vtweg
spart
fkart
land1
fkdat
kunrg
knumv
waerk
kurrf
vkbur_i
vkgrp_i
matnr_i
vrkme_i
fkimg_i
matkl_i
posnr_i
netwr_i
augru_auft_i
aubel_i
vgbel_i
pstyv_i
vstel_i
prctr_i
FROM wb2_v_vbrk_vbrp2 INTO corresponding fields of TABLE it_vbrk
WHERE
vkorg = p_vkorg AND
vtweg = '30' AND
spart IN so_spart AND
kunrg IN so_kunrg AND
fkart IN so_fkart AND
vbeln_i IN so_vbeln AND
fkdat IN so_fkdat AND
vkbur_i IN so_vkbur AND
vkgrp_i IN so_vkgrp AND
matnr_i IN so_matnr AND
fkimg_i <> '0'.
sort it_vbrk by vbeln_i knumv posnr_i.
IF it_vbrk[] IS NOT INITIAL.
SELECT
knumv
kposn
stunr
kschl
krech
kbetr
kpein
waers
kmein
kkurs
kinak
FROM konv INTO TABLE it_konv
FOR ALL ENTRIES IN it_vbrk
WHERE knumv = it_vbrk-knumv AND
kschl IN ('ZPR0','Z305','ZCCM','ZFCM').
sort it_konv by knumv.
SELECT
belnr
hkont
prctr
dmbtr
matnr
werks
FROM bseg INTO TABLE it_fin
FOR ALL ENTRIES IN it_vbrk
WHERE belnr = it_vbrk-vbeln_i AND
matnr = it_vbrk-matnr_i AND
werks = it_vbrk-vstel_i AND
prctr = it_vbrk-prctr_i.
sort it_fin by belnr.
LOOP AT it_vbrk INTO wa_vbrk.
wa_data-vbeln = wa_vbrk-vbeln_i.
wa_data-vkbur = wa_vbrk-vkbur_i.
wa_data-vkgrp = wa_vbrk-vkgrp_i.
wa_data-matnr = wa_vbrk-matnr_i.
wa_data-vrkme = wa_vbrk-vrkme_i.
wa_data-matkl = wa_vbrk-matkl_i.
wa_data-posnr = wa_vbrk-posnr_i.
wa_data-netwr = wa_vbrk-netwr_i.
wa_data-reas = wa_vbrk-reas_i.
wa_data-aubel = wa_vbrk-aubel_i.
wa_data-vgbel = wa_vbrk-vgbel_i.
wa_data-pstyv = wa_vbrk-pstyv_i.
wa_data-vkorg = wa_vbrk-vkorg.
wa_data-vtweg = wa_vbrk-vtweg.
wa_data-spart = wa_vbrk-spart.
wa_data-fkart = wa_vbrk-fkart.
wa_data-land1 = wa_vbrk-land1.
wa_data-fkdat = wa_vbrk-fkdat.
wa_data-kunrg = wa_vbrk-kunrg.
wa_data-knumv = wa_vbrk-knumv.
wa_data-waerk = wa_vbrk-waerk.
wa_data-kurrf = wa_vbrk-kurrf.
wa_data-prctr = wa_vbrk-prctr_i.
wa_data-vstel = wa_vbrk-vstel_i.
* move-corresponding wa_vbrk to wa_data.
READ TABLE it_fin WITH KEY belnr = wa_data-vbeln matnr = wa_data-matnr.
if it_fin-belnr = wa_data-vbeln.
wa_data-hkont = it_fin-hkont.
SELECT SINGLE txt20 INTO wa_data-gltxt FROM skat WHERE spras = 'EN' AND saknr = wa_data-hkont AND ktopl = '1000'.
endif.
SELECT SINGLE maktx FROM makt INTO wa_data-maktx WHERE matnr = wa_data-matnr.
SELECT SINGLE zeinr matkl FROM mara INTO (wa_data-zeinr,wa_data-matkl) WHERE matnr = wa_data-matnr.
SELECT SINGLE bezei FROM tvkbt INTO wa_data-soff WHERE vkbur = wa_data-vkbur AND spras = 'E'.
SELECT SINGLE bezei FROM tvgrt INTO wa_data-sgrp WHERE vkgrp = wa_data-vkgrp AND spras = 'E'.
SELECT SINGLE vtext INTO wa_data-division FROM tspat WHERE spart = wa_data-spart AND spras = 'EN'.
* added on 23.06.2008
READ TABLE it_konv INTO wa_konv WITH KEY knumv = wa_data-knumv kposn = wa_data-posnr kschl = 'ZPR0' kinak = ''.
wa_data-kschl = wa_konv-kschl.
wa_data-kposn = wa_konv-kposn.
wa_data-stunr = wa_konv-stunr.
wa_data-kbetr = wa_konv-kbetr.
wa_data-kpein = wa_konv-kpein.
wa_data-kkurs = wa_konv-kkurs.
* This is calculating per unit rate
wa_data-rate = ( wa_data-kbetr * wa_data-kpein ) / wa_data-kpein .
wa_data-drate = wa_data-rate.
CLEAR wa_konv.
READ TABLE it_konv INTO wa_konv WITH KEY knumv = wa_data-knumv kposn = wa_data-posnr kschl = 'Z305' krech = 'A'.
IF wa_konv-kbetr <> 0.
wa_data-kbetr1 = ABS( wa_konv-kbetr ).
wa_data-drate = wa_data-rate - ( wa_data-rate * ( ( wa_data-kbetr1 / 10 ) / 100 ) ).
wa_data-dperc = ( wa_data-kbetr1 / 10 ).
IF wa_data-fkart = 'S1' OR wa_data-fkart = 'RE' OR wa_data-fkart = 'ZRES' OR wa_data-fkart = 'Z2RE' OR wa_data-fkart = 'G2' .
IF wa_data-pstyv = 'TANN' OR wa_data-pstyv = 'ZMOH' OR wa_data-pstyv = 'ZPHY' OR wa_data-pstyv = 'ZSAM' OR wa_data-pstyv = 'ZZNN' OR wa_data-pstyv = 'ZREN1'.
* IF WA_DATA-PSTYV = 'TANN' OR WA_DATA-PSTYV = 'ZMOH' OR WA_DATA-PSTYV = 'ZPHY' OR WA_DATA-PSTYV = 'ZSAM' or wa_data-pstyv = 'ZZNN'.
wa_data-total = '0'.
wa_data-fkimg = wa_vbrk-fkimg_i * -1.
ELSE.
wa_data-fkimg = wa_vbrk-fkimg_i * -1.
wa_data-total = ( ( wa_data-fkimg * wa_data-drate ) ) / wa_data-kpein.
wa_data-inrvalue = wa_data-total * wa_data-kurrf.
ENDIF.
ELSE.
IF wa_data-pstyv = 'TANN' OR wa_data-pstyv = 'ZMOH' OR wa_data-pstyv = 'ZPHY' OR wa_data-pstyv = 'ZSAM' OR wa_data-pstyv = 'ZZNN'.
wa_data-fkimg = wa_vbrk-fkimg_i.
wa_data-total = '0'.
wa_data-inrvalue = wa_data-total * wa_data-kurrf.
ELSE.
wa_data-fkimg = wa_vbrk-fkimg_i.
wa_data-total = ( wa_data-fkimg * wa_data-drate ) / wa_data-kpein.
wa_data-inrvalue = wa_data-total * wa_data-kurrf.
ENDIF.
ENDIF.
ELSE.
READ TABLE it_konv INTO wa_konv WITH KEY knumv = wa_data-knumv kposn = wa_data-posnr kschl = 'Z305' krech = 'B'.
IF wa_konv-kbetr <> 0.
wa_data-kbetr1 = ABS( wa_konv-kbetr ).
wa_data-drate = wa_data-rate.
wa_data-dvalue = wa_data-kbetr1.
IF wa_data-fkart = 'S1' OR wa_data-fkart = 'RE' OR wa_data-fkart = 'ZRES' OR wa_data-fkart = 'Z2RE' OR wa_data-fkart = 'G2' .
IF wa_data-pstyv = 'TANN' OR wa_data-pstyv = 'ZMOH' OR wa_data-pstyv = 'ZPHY' OR wa_data-pstyv = 'ZSAM' OR wa_data-pstyv = 'ZZNN' OR wa_data-pstyv = 'ZREN1'.
* IF WA_DATA-PSTYV = 'TANN' OR WA_DATA-PSTYV = 'ZMOH' OR WA_DATA-PSTYV = 'ZPHY' OR WA_DATA-PSTYV = 'ZSAM' or wa_data-pstyv = 'ZZNN'.
wa_data-total = '0'.
wa_data-fkimg = wa_vbrk-fkimg_i * -1.
ELSE.
wa_data-fkimg = wa_vbrk-fkimg_i * -1.
wa_data-total = ( ( wa_data-fkimg * wa_data-rate ) - wa_data-kbetr1 ) * -1.
wa_data-inrvalue = wa_data-total * wa_data-kurrf.
ENDIF.
ELSE.
IF wa_data-pstyv = 'TANN' OR wa_data-pstyv = 'ZMOH' OR wa_data-pstyv = 'ZPHY' OR wa_data-pstyv = 'ZSAM' OR wa_data-pstyv = 'ZZNN'.
wa_data-fkimg = wa_vbrk-fkimg_i.
wa_data-total = '0'.
wa_data-inrvalue = wa_data-total * wa_data-kurrf.
ELSE.
wa_data-fkimg = wa_vbrk-fkimg_i.
wa_data-total = ( ( wa_data-fkimg * wa_data-rate ) - wa_data-kbetr1 ).
wa_data-inrvalue = wa_data-total * wa_data-kurrf.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
CLEAR wa_konv.
IF wa_data-kbetr1 EQ '0'.
IF wa_data-fkart = 'S1' OR wa_data-fkart = 'RE' OR wa_data-fkart = 'ZRES' OR wa_data-fkart = 'Z2RE' OR wa_data-fkart = 'G2' .
IF wa_data-pstyv = 'TANN' OR wa_data-pstyv = 'ZMOH' OR wa_data-pstyv = 'ZPHY' OR wa_data-pstyv = 'ZSAM' OR wa_data-pstyv = 'ZZNN' OR wa_data-pstyv = 'ZREN1'.
* IF WA_DATA-PSTYV = 'TANN' OR WA_DATA-PSTYV = 'ZMOH' OR WA_DATA-PSTYV = 'ZPHY' OR WA_DATA-PSTYV = 'ZSAM' or wa_data-pstyv = 'ZZNN'.
wa_data-total = '0'.
wa_data-fkimg = wa_vbrk-fkimg_i * -1.
ELSE.
wa_data-fkimg = wa_vbrk-fkimg_i * -1.
wa_data-total = ( ( wa_data-fkimg * wa_data-drate ) ) / wa_data-kpein.
wa_data-inrvalue = wa_data-total * wa_data-kurrf.
ENDIF.
ELSE.
IF wa_data-pstyv = 'TANN' OR wa_data-pstyv = 'ZMOH' OR wa_data-pstyv = 'ZPHY' OR wa_data-pstyv = 'ZSAM' OR wa_data-pstyv = 'ZZNN'.
wa_data-fkimg = wa_vbrk-fkimg_i.
wa_data-total = '0'.
wa_data-inrvalue = wa_data-total * wa_data-kurrf.
ELSE.
wa_data-fkimg = wa_vbrk-fkimg_i.
wa_data-total = ( wa_data-fkimg * wa_data-drate ) / wa_data-kpein.
wa_data-inrvalue = wa_data-total * wa_data-kurrf.
ENDIF.
ENDIF.
ENDIF.
SELECT SINGLE name1 land1 FROM kna1 INTO (wa_data-name1,wa_data-land1) WHERE kunnr = wa_data-kunrg.
SELECT SINGLE landx FROM t005t INTO wa_data-landx WHERE land1 = wa_data-land1 AND spras = 'EN'.
SELECT SINGLE wgbez FROM t023t INTO wa_data-wgbez WHERE matkl = wa_data-matkl.
SELECT SINGLE bezei FROM tvm1t INTO wa_data-bezei WHERE mvgr1 = wa_data-mvgr3.
SELECT SINGLE bezei FROM tvm1t INTO wa_data-bezei1 WHERE mvgr1 = wa_data-mvgr4.
APPEND wa_data TO it_data.
Please reply...
Thanks,
Regards,
JiteshHi,
Dont put select quaries in loop. Its affect performance.First collect all the data in temporary tables.
then read these tables according to the data collected in final table.
Also use ranges for select quary of konv.
also use sort table & make indexing like this.
for example:
w_index = sy-index + 1.
READ TABLE it_vbrk INTO wa_vbrk INDEX w_index.
IF sy-subrc EQ 0.
w_tabix = sy-tabix + w_tabix.
LOOP AT it_vbrk INTO wa_vbrk FROM w_tabix.
endloop.
endif.
or u can use hashed table with unique keys.
Also check in se30 whether the coding takes time or database fetching takes time.
Regards,
Anagha Deshmukh -
Query tuning for fast retrivel of data.
Hi,
I am having a main function which returns a ref cursor.
1.Inside this function we are using a cursor which fetches 400 record of data.Inside the same function we are using an another function which return data in tab type.
2.the logic inside the main function is based on the condition the in the cusor loop a branch value is compared with the one branch column in tab type if both are equal then we are inserting data into another tab type.
3.In the main function only we are calling another function,were we send one of the parameter as tab type.
the below is code..
FUNCTION get_wb_for_rte(p_rte_id NUMBER,
p_br_id NUMBER,
p_mod_id NUMBER,
p_part_data NUMBER)
RETURN OPS_SAFEX_UTL.CURSORTYP as
CURSOR c_wb_unld_hub is
SELECT DISTINCT ow.id id,'N' excs
FROM ops_waybl ow,
ops_wb_mfst owm,
ops_prov_ult opu,
ops_pult_wb_dtls opwd,
ops_uult_wb_dtls ouuwd
WHERE ow.id =owm. waybl_id
AND owm.id=opwd.wb_mfst_id
AND opwd.id=ouuwd.pult_wb_dtls_id
AND opwd.prov_ult_id=opu.id
AND opu.from_br_mast_id=p_br_id
AND ops_hub_utl.get_avlpkgs_ld(ow.id)>0
UNION
SELECT DISTINCT ouer.waybl_id id, 'Y' excs
FROM ops_uult_excess_recd ouer
WHERE ops_hub_utl.get_avl_xs_pkgs_ld(ouer.waybl_id)>0
ORDER BY id;
BEGIN
track_flag:=1;
v_wb_dtls(1):=null;
v_dest_br := ops_safex_utl.get_dest_br_for_rte(p_rte_id,p_br_id);
If (v_dest_br(1)=2) then
track_flag:=2;
for rec_wb_unld_hub in c_wb_unld_hub loop
v_br_id := ops_safex_utl.get_wb_dest_id (rec_wb_unld_hub.id);
for v_dest_ptr in v_dest_br.first+1..v_dest_br.last loop
IF v_br_id=v_dest_br(v_dest_ptr) THEN
v_wb_ptr:=v_wb_ptr+1;
dbms_output.put_line(rec_wb_unld_hub.id);
v_wb_dtls(v_wb_ptr).id:=rec_wb_unld_hub.id;
v_wb_dtls(v_wb_ptr).excs:=rec_wb_unld_hub.excs;
end if;
end loop;
end loop;
track_flag:=3;
v_qry_str := ops_hub_utl.get_wb_dtls(v_wb_dtls,p_part_data,p_rte_id,p_br_id);
end if;
open cur1 for v_qry_str;
RETURN cur1;
END get_wb_for_rte;
this function is taking nealry 12 min ..in the mean while the application is getting timed out.
we are having one more idea of using temporary tables instead of cursors..please advice which will be good in performance point of aspect.
Please advice .
Thanks & Regards
sudhir3.Actually the major performance issue is comming up at cusor loop where i am comparing the curosr data with the data in tab type.(i.e) i need to compare each row with all the rows in the tab type..there it is taking much time.Once the Branch value is matched why bother to iterate though the rest of the records from the inner loop. The EXIT will come out of the inner loop when matched and continue with the rest of the records from the cursor – Outer loop
for v_dest_ptr in v_dest_br.first+1..v_dest_br.last loop
IF v_br_id=v_dest_br(v_dest_ptr) THEN
v_wb_ptr:=v_wb_ptr+1;
dbms_output.put_line(rec_wb_unld_hub.id);
v_wb_dtls(v_wb_ptr).id := rec_wb_unld_hub.id;
v_wb_dtls(v_wb_ptr).excs := rec_wb_unld_hub.excs;
EXIT;
end if;
end loop;
end loop;
Shailender Mehta -
Grep expression for specific search within Brackets
Hello,
I did a search and found many topics for searching within brackets, but wasn't able to find anything to search for specific characters/quotation within brackets.
Note: The forum image uploader wasn't working for me so I embedded it to the topic. Hopefully it shows up for you. (http://cl.ly/1H42302P2x3c1Q3P2a42)
For the Brackets and words within, i use: (\[).+?(\])
and have it them to a different font.
For my project i need the quotations to be a different color and nothing else.
These are the ones i'm trying to add to an expression: '|"|;|,
Any help is very much appreciated. I've been trying many arrangements with no luck. Thanks!It's not possible to search for your punctuation inside parentheses only. (FYI, that needs a positive lookbehind of variable length, and that's not possible.)
But the hint to get it done is right there:
function(){return A.apply(null,[this].concat($A(arguments)))}
For the Brackets and words within, i use: (\[).+?(\])
and have it them to a different font.
Simply search for your set
only in that particular font. -
Search error in Content server
Hi All,
We have Migrated documents from IPM 10 g to IPM 11g.
Now currently we are working in Production environment.
But whenever I search for documents in UCM I am getting Following error
Unable to retrieve search results. Error occurred while processing. Unable to return results. Unable to create the result set for query 'SELECT Revisions.dID, dDocTitle, dDocType, dRevisionID, dSecurityGroup, dDocAuthor, dDocAccount, dRevLabel, dFormat, dOriginalName, dExtension, dWebExtension, dInDate, dOutDate, dCreateDate, dPublishType, dRendition1, dRendition2, dFileSize AS VaultFileSize, DocMeta.*, RevClasses.* FROM Revisions, DocMeta, Documents, RevClasses
WHERE Revisions.dID=DocMeta.dID And Revisions.dID=Documents.dID And Revisions.dDocName = RevClasses.dDocName And dIsPrimary = 1 And dReleaseState IN ('Y', 'U', 'I') ORDER BY dInDate Desc'. [FMWGEN][SQLServer JDBC Driver]Execution timeout expired. java.sql.SQLTimeoutException: [FMWGEN][SQLServer JDBC Driver]Execution timeout expired..
Please somebody help me..
Thanks in advance
vikasSrinath Menon wrote:SELECT Revisions.dID, dDocTitle, dDocType, dRevisionID, dSecurityGroup, dDocAuthor, dDocAccount, dRevLabel, dFormat, dOriginalName, dExtension, dWebExtension, dInDate, dOutDate, dCreateDate, dPublishType, dRendition1, dRendition2, dFileSize AS VaultFileSize, DocMeta., RevClasses. FROM Revisions, DocMeta, Documents, RevClassesWHERE Revisions.dID=DocMeta.dID And Revisions.dID=Documents.dID And Revisions.dDocName = RevClasses.dDocName And dIsPrimary = 1 And dReleaseState IN ('Y', 'U', 'I') ORDER BY dInDate Desc
Execute the above query on the DB directly and see if that brings up the results .>
It looks like you may not have followed Srinath's instructions exactly. You edited your query to include a schema namespace, which defeats the purpose of running the query that the system is actually attempting to execute. Please run the exact query that was requested, since that's the query the system is actually running.
If you run the query as posted in the original error (and included in Srinath's request), I would expect it to fail, as it appears to be malformed (see "DocMeta., RevClasses."). The trailing dots are probably the issue, and they shouldn't be there.
If you cannot execute a search directly in the Content Server interface successfully, please post which search engine is being used. The query above is actually part of a query called a datasource. This particular datasource has been used for many years and is quite stable. I'd imagine that something else (like a customization or some other productized component) is the culprit, especially if the standard search within the Content Server itself is no longer working. -
hello all
my one of query is returning result in 1-2 mins only for 1 lakh record but i am not sure if it showed me complete rows or not because when I an trying to get count of result ..its taking lot of time .when I am using this query on plsql code ..code is running slow so just wanted to confirm on query tuning point of view if its fine or not ..please look onto it and let me know if query is fine or not by explain plan .my oracle version is 11g
this is my query
SELECT ROWNUM , TRUNC(rownum/5000) + 20000 ,'FOR_UPDATE', sku_org.NAME ,
acct_promo_sku.src_num , acct_promo_sku.sub_type ,
promo_actual.sku_actual_pos
FROM siebel.s_src acct_promo_hdr,
siebel.s_src acct_title_format,
siebel.s_src acct_promo_sku,
siebel.s_src_x acct_promo_hdrx,
siebel.s_src_x acct_promo_skux,
siebel.s_prod_int prod,
siebel.s_bu promo_hdr_org,
siebel.s_bu sku_org,
siebelwb.stg_sbl_acct_promo_actuals2 promo_actual
WHERE acct_promo_hdr.sub_type = 'PLAN_ACCOUNT_PROMOTION'
AND acct_promo_hdr.row_id = acct_title_format.par_src_id
AND acct_title_format.sub_type = 'PLAN_ACCT_PROMOTION_CATEGORY'
AND acct_title_format.row_id = acct_promo_sku.par_src_id
AND acct_promo_sku.sub_type = 'PLAN_ACCOUNT_PROMOTION_PRODUCT'
AND acct_promo_hdr.row_id = acct_promo_hdrx.par_row_id
AND acct_promo_sku.row_id = acct_promo_skux.par_row_id(+)
AND acct_promo_sku.prod_id = prod.row_id
AND acct_promo_hdr.bu_id = promo_hdr_org.row_id
AND acct_promo_sku.bu_id = sku_org.row_id
AND prod.x_prod_material_num = promo_actual.material_number
and prod.X_PROD_SALES_ORG=promo_actual.sales_org
AND acct_promo_hdr.row_id = promo_actual.acct_promo_id
and nvl(acct_promo_hdr.pr_accnt_id,0)=nvl(promo_actual.acct_siebel_rowid,0)
and nvl(acct_promo_hdr.x_indirect_id,0)=nvl(promo_actual.indirect_acct_siebel_rowid,0)
AND promo_actual.load_date >= TRUNC(SYSDATE)
AND promo_actual.load_date < TRUNC(SYSDATE + 1)
explain plan
PLAN_TABLE_OUTPUT
Plan hash value: 3864590768
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 298 | 2300 (1)| 00:00:28 |
| 1 | COUNT | | | | | |
|* 2 | FILTER | | | | | |
| 3 | NESTED LOOPS | | | | | |
| 4 | NESTED LOOPS | | 1 | 298 | 2300 (1)| 00:00:28 |
| 5 | NESTED LOOPS OUTER | | 1 | 273 | 2298 (1)| 00:00:28 |
| 6 | NESTED LOOPS | | 1 | 263 | 2296 (1)| 00:00:28 |
| 7 | NESTED LOOPS | | 1 | 236 | 2295 (1)| 00:00:28 |
| 8 | NESTED LOOPS | | 1 | 165 | 2292 (1)| 00:00:28 |
| 9 | NESTED LOOPS | | 1 | 117 | 2289 (1)| 00:00:28 |
| 10 | NESTED LOOPS | | 1 | 109 | 2289 (1)| 00:00:28 |
| 11 | NESTED LOOPS | | 1 | 99 | 2287 (1)| 00:00:28 |
|* 12 | TABLE ACCESS FULL | STG_SBL_ACCT_PROMO_ACTUALS2 | 1 | 49 | 2285 (1)| 00:0
|* 13 | TABLE ACCESS BY INDEX ROWID| S_SRC | 1 | 50 | 2 (0)| 00:00:01 |
|* 14 | INDEX UNIQUE SCAN | S_SRC_P1 | 1 | | 1 (0)| 00:00:01 |
|* 15 | INDEX RANGE SCAN | S_SRC_X_U1 | 1 | 10 | 2 (0)| 00:00:01 |
|* 16 | INDEX UNIQUE SCAN | S_BU_P1 | 1 | 8 | 0 (0)| 00:00:01 |
|* 17 | TABLE ACCESS BY INDEX ROWID | S_SRC | 1 | 48 | 3 (0)| 00:00:01 |
|* 18 | INDEX RANGE SCAN | S_SRC_F2 | 2 | | 2 (0)| 00:00:01 |
|* 19 | TABLE ACCESS BY INDEX ROWID | S_SRC | 1 | 71 | 3 (0)| 00:00:01 |
|* 20 | INDEX RANGE SCAN | S_SRC_F2 | 2 | | 2 (0)| 00:00:01 |
| 21 | TABLE ACCESS BY INDEX ROWID | S_BU | 1 | 27 | 1 (0)| 00:00:01 |
|* 22 | INDEX UNIQUE SCAN | S_BU_P1 | 1 | | 0 (0)| 00:00:01 |
|* 23 | INDEX RANGE SCAN | S_SRC_X_U1 | 1 | 10 | 2 (0)| 00:00:01 |
|* 24 | INDEX UNIQUE SCAN | S_PROD_INT_P1 | 1 | | 1 (0)| 00:00:01 |
|* 25 | TABLE ACCESS BY INDEX ROWID | S_PROD_INT | 1 | 25 | 2 (0)| 00:00:
Predicate Information (identified by operation id):
2 - filter(TRUNC(SYSDATE@!)<TRUNC(SYSDATE@!+1))
12 - filter("PROMO_ACTUAL"."LOAD_DATE">=TRUNC(SYSDATE@!) AND "PROMO_ACTUAL"."LOAD_DATE"<TRUNC(SYSD
13 - filter("ACCT_PROMO_HDR"."SUB_TYPE"='PLAN_ACCOUNT_PROMOTION' AND
NVL("ACCT_PROMO_HDR"."PR_ACCNT_ID",'0')=NVL("PROMO_ACTUAL"."ACCT_SIEBEL_ROWID",'0') AND
NVL("ACCT_PROMO_HDR"."X_INDIRECT_ID",'0')=NVL("PROMO_ACTUAL"."INDIRECT_ACCT_SIEBEL_ROWID",'0'
14 - access("ACCT_PROMO_HDR"."ROW_ID"="PROMO_ACTUAL"."ACCT_PROMO_ID")
15 - access("ACCT_PROMO_HDR"."ROW_ID"="ACCT_PROMO_HDRX"."PAR_ROW_ID")
16 - access("ACCT_PROMO_HDR"."BU_ID"="PROMO_HDR_ORG"."ROW_ID")
17 - filter("ACCT_TITLE_FORMAT"."SUB_TYPE"='PLAN_ACCT_PROMOTION_CATEGORY')
18 - access("ACCT_PROMO_HDR"."ROW_ID"="ACCT_TITLE_FORMAT"."PAR_SRC_ID")
19 - filter("ACCT_PROMO_SKU"."PROD_ID" IS NOT NULL AND
"ACCT_PROMO_SKU"."SUB_TYPE"='PLAN_ACCOUNT_PROMOTION_PRODUCT')
20 - access("ACCT_TITLE_FORMAT"."ROW_ID"="ACCT_PROMO_SKU"."PAR_SRC_ID")
22 - access("ACCT_PROMO_SKU"."BU_ID"="SKU_ORG"."ROW_ID")
23 - access("ACCT_PROMO_SKU"."ROW_ID"="ACCT_PROMO_SKUX"."PAR_ROW_ID"(+))
24 - access("ACCT_PROMO_SKU"."PROD_ID"="PROD"."ROW_ID")
25 - filter("PROD"."X_PROD_MATERIAL_NUM" IS NOT NULL AND
"PROD"."X_PROD_MATERIAL_NUM"="PROMO_ACTUAL"."MATERIAL_NUMBER" AND
"PROD"."X_PROD_SALES_ORG"="PROMO_ACTUAL"."SALES_ORG")
55 rows selected.
thanksHi,
the plan you posted has the cost of 2300, i.e. 2300 single-block reads or equivalent number f multi-block reads. Even if none of the blocks is found in cache, 2300 reas shouldn't take more than a couple of minutes, beacause for most of the hard drives available today a disk read is typically within 5-10 ms.
This means that if there is a problem, we will never find out about it by looking in the plan. And it's quite likely that there is, in fact, a problem, because the plan contains a bunch of nested joins, and the cost of each nested join is directly proportional to the cardinality of the previous nested loop. I.e. it suffices to make one bad mistake in estimating the number of rows coming fom one of the nested rows to screw up the entire plan and get all remaining estimates (including the total cost of the query) completely wrong.
In order for us to be able to tell more, we need to see the plan with rowsource statistics, and please don't forget to use tags to preserve formatting (use the preview tab to make sure the posted plan is actually readable).
Best regards,
Nikolay -
KQL for getting documents in Content Search Webpart
Hi Guys,
How do I get the documents grouped by document sets and sites for the current user using KQL in content search web part in SharePoint 2013?
Thanks in advance.
nasayooHi nasayoo,
In content search web part, there is OOB option to group results based on one or more managed properties. You could go to refiners tab when configure query of web part, then click Show more, under groups results, set it to group result per your requirement.
http://technet.microsoft.com/en-us/library/jj679900(v=office.15).aspx#BKMK_ConfigureWP
In addition, here is an article which provides methods using JavaScript to define a custom group display template for search web part:
http://www.eliostruyf.com/how-to-define-a-custom-group-display-template-for-the-search-results-webpart-via-javascript/
Regards,
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected] .
Rebecca Tu
TechNet Community Support -
Please reply for the query tuning
Hi, i am a beginner in oracle dba, I have to know if i have studied little bit about query tuning in ORACLE.
I wanna know if i have the following query and its plan then how it can be tuned:
QUERY:
SELECT z.emplid ,h.first_name || ' ' || h.last_name ,z.grade ,z.DEPTID ,z.LOCATION
FROM sysadm.ps_lnt_latestbu_vw z, sysadm.ps_personal_data h
WHERE z.empl_status ='A' --index access
AND z.emplid = h.emplid --join
and z.emplid not in (select g.emplid from sysadm.ps_lnt_asn_skl_tbl g) --join
and z.Business_unit=
( select l.lnt_subunit from sysadm.ps_position_data l where l.position_nbr in
( select b.position_nbr from sysadm.ps_job b,sysadm.psoprdefn y
where b.effdt=( select max(g.effdt) from sysadm.ps_job g
where g.emplid=b.emplid --join costs high
and g.effdt<=SYSDATE) --filter/index
and b.effseq=
(select max(h.effseq) from sysadm.ps_job h
where h.emplid=b.emplid --join costs high
and h.effdt=b.effdt) --join costs high
and b.empl_rcd=0 --filter/index access
and y.EMPLID=b.EMPLID --join
and y.OPRID='1112' -- filter/index access
order by z.emplid
/AND its plan is:
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=6 Card=1 Bytes=64)
1 0 SORT (ORDER BY) (Cost=6 Card=1 Bytes=64)
2 1 NESTED LOOPS (ANTI) (Cost=4 Card=1 Bytes=64)
3 2 NESTED LOOPS (Cost=3 Card=1 Bytes=56)
4 3 VIEW OF 'PS_LNT_LATESTBU_VW' (Cost=2 Card=1 Bytes=31)
5 4 UNION-ALL
6 5 CONCATENATION
7 6 TABLE ACCESS (BY INDEX ROWID) OF 'PS_POSITION_DATA' (Cost=5 Card=90 Bytes=1890)
8 7 NESTED LOOPS
9 8 NESTED LOOPS (Cost=275 Card=1 Bytes=90)
10 9 NESTED LOOPS (Cost=275 Card=1 Bytes=82)
11 10 TABLE ACCESS (BY INDEX ROWID) OF 'PS_JOB' (Cost=3 Card=1 Bytes=50)
12 11 INDEX (RANGE SCAN) OF 'PS2JOB' (NON-UNIQUE) (Cost=2 Card=1)
13 12 SORT (AGGREGATE)
14 13 FIRST ROW (Cost=3 Card=1 Bytes=19)
15 14 INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=207700)
16 12 SORT (AGGREGATE)
17 16 FIRST ROW (Cost=3 Card=1 Bytes=22)
18 17 INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=207700)
19 10 INDEX (UNIQUE SCAN) OF 'PS_EMPLOYMENT'(UNIQUE)
20 9 INDEX (UNIQUE SCAN) OF 'PS_PERSONAL_DATA' (UNIQUE)
21 8 INDEX (RANGE SCAN) OF 'PS_POSITION_DATA' (UNIQUE) (Cost=5 Card=90)
22 6 FILTER
23 22 NESTED LOOPS (Cost=275 Card=1 Bytes=90)
24 23 NESTED LOOPS (Cost=275 Card=1 Bytes=82)
25 24 NESTED LOOPS (Cost=275 Card=1 Bytes=71)
26 25 INDEX (FAST FULL SCAN) OF 'PS8POSITION_DATA' (NON-UNIQUE) (Cost=5 Card=90 Bytes=1890)
27 25 TABLE ACCESS (BY INDEX ROWID) OF 'PS_JOB' (Cost=3 Card=1 Bytes=50)
28 27 INDEX (RANGE SCAN) OF 'PS2JOB' (NON-UNIQUE) (Cost=2 Card=1)
29 28 SORT (AGGREGATE)
30 29 FIRST ROW (Cost=3 Card=1 Bytes=22)
31 30 INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=207700)
32 28 SORT (AGGREGATE)
33 32 FIRST ROW (Cost=3 Card=1 Bytes=19)
34 33 INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=207700)
35 24 INDEX (UNIQUE SCAN) OF 'PS_EMPLOYMENT' (UNIQUE)
36 23 INDEX (UNIQUE SCAN) OF 'PS_PERSONAL_DATA'(UNIQUE)
37 22 SORT (AGGREGATE)
38 37 FIRST ROW (Cost=2 Card=1 Bytes=17)
39 38 INDEX (RANGE SCAN (MIN/MAX)) OF 'PS_POSITION_DATA' (UNIQUE) (Cost=2 Card=9000)
40 5 FILTER
41 40 NESTED LOOPS (Cost=751 Card=1 Bytes=191)
42 41 NESTED LOOPS (OUTER) (Cost=750 Card=1 Bytes=167)
43 42 NESTED LOOPS (OUTER) (Cost=749 Card=1 Bytes=143)
44 43 NESTED LOOPS (Cost=748 Card=1 Bytes=134)
45 44 NESTED LOOPS (Cost=748 Card=1 Bytes=123)
46 45 NESTED LOOPS (Cost=748 Card=1 Bytes=119)
47 46 NESTED LOOPS (Cost=747 Card=1 Bytes=98)
48 47 NESTED LOOPS (Cost=744 Card=1 Bytes=62)
49 48 NESTED LOOPS (Cost=744 Card=1Bytes=54)
50 49 VIEW OF 'PS_LNTPRJOBSYSJRVW'(Cost=741 Card=1 Bytes=9)
51 50 FILTER
52 51 NESTED LOOPS (OUTER) (Cost=735 Card=1 Bytes=68)
53 52 NESTED LOOPS (Cost=734Card=1 Bytes=51)
54 53 NESTED LOOPS (Cost=734 Card=1 Bytes=43)
55 54 TABLE ACCESS (BY INDEX ROWID) OF 'PS_JOB' (Cost=734 Card=1 Bytes=32)
56 55 INDEX (RANGE SCAN) OF 'PSCJOB' (NON-UNIQUE) (Cost=206 Card=1013)
57 54 INDEX (UNIQUE SCAN) OF 'PS_EMPLOYMENT' (UNIQUE)
58 53 INDEX (UNIQUE SCAN) OF 'PS_PERSONAL_DATA' (UNIQUE)
59 52 INDEX (RANGE SCAN) OF'PS_POSITION_DATA' (UNIQUE) (Cost=1 Card=1 Bytes=17)
60 51 SORT (AGGREGATE)
61 60 FIRST ROW (Cost=3 Card=1 Bytes=19)
62 61 INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=207700)
63 51 SORT (AGGREGATE)
64 63 FIRST ROW (Cost=3 Card=1 Bytes=22)
65 64 INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=207700)
66 51 SORT (AGGREGATE)
67 66 FIRST ROW (Cost=2 Card=1 Bytes=17)
68 67 INDEX (RANGE SCAN (MIN/MAX)) OF 'PS_POSITION_DATA' (UNIQUE) (Cost=2 Card=9000)
69 49 TABLE ACCESS (BY INDEX ROWID) OF 'PS_JOB' (Cost=3 Card=1 Bytes=45)
70 69 INDEX (RANGE SCAN) OF 'PSAJOB' (NON-UNIQUE) (Cost=2 Card=1)
71 70 SORT (AGGREGATE)
72 71 INDEX (RANGE SCAN) OF'PSAJOB' (NON-UNIQUE) (Cost=3 Card=1 Bytes=19)
73 72 SORT (AGGREGATE)
74 73 FIRST ROW (Cost=3Card=8 Bytes=88)
75 74 INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=25963)
76 70 SORT (AGGREGATE)
77 76 FIRST ROW (Cost=3 Card=8 Bytes=88)
78 77 INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=25963)
79 48 INDEX (UNIQUE SCAN) OF 'PS_PERSONAL_DATA' (UNIQUE)
80 47 TABLE ACCESS (BY INDEX ROWID) OF'PS_JOB' (Cost=3 Card=1 Bytes=36)
81 80 INDEX (RANGE SCAN) OF 'PSAJOB'(NON-UNIQUE) (Cost=2 Card=1)
82 81 SORT (AGGREGATE)
83 82 FIRST ROW (Cost=3 Card=1 Bytes=19)
84 83 INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=207700)
85 81 SORT (AGGREGATE)
86 85 FIRST ROW (Cost=3 Card=1 Bytes=22)
87 86 INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=207700)
88 46 INDEX (RANGE SCAN) OF 'PS8POSITION_DATA' (NON-UNIQUE) (Cost=1 Card=1 Bytes=21)
89 45 INDEX (UNIQUE SCAN) OF 'PS_BUS_UNIT_TBL_HR' (UNIQUE)
90 44 INDEX (UNIQUE SCAN) OF 'PS_EMPLOYMENT'(UNIQUE)
91 43 INDEX (RANGE SCAN) OF 'PS_POSITION_DATA'(UNIQUE) (Cost=1 Card=1 Bytes=9)
92 42 INDEX (FULL SCAN) OF 'PS0LOCATION_TBL' (NON-UNIQUE) (Cost=1 Card=1 Bytes=24)
93 41 INDEX (RANGE SCAN) OF 'PS0LOCATION_TBL' (NON-UNIQUE) (Cost=1 Card=1 Bytes=24)
94 40 SORT (AGGREGATE)
95 94 FIRST ROW (Cost=2 Card=1 Bytes=17)
96 95 INDEX (RANGE SCAN (MIN/MAX)) OF 'PS_POSITION_DATA' (UNIQUE) (Cost=2 Card=9000)
97 4 TABLE ACCESS (BY INDEX ROWID) OF 'PS_POSITION_DATA' (Cost=2 Card=1 Bytes=13)
98 97 NESTED LOOPS (Cost=9 Card=1 Bytes=19)
99 98 VIEW OF 'VW_NSO_1' (Cost=5 Card=1 Bytes=6)
100 99 SORT (UNIQUE)
101 100 NESTED LOOPS (Cost=5 Card=1 Bytes=44)
102 101 TABLE ACCESS (BY INDEX ROWID) OF 'PSOPRDEFN' (Cost=2 Card=1 Bytes=14)
103 102 INDEX (UNIQUE SCAN) OF 'PS_PSOPRDEFN'(UNIQUE) (Cost=1 Card=1)
104 101 TABLE ACCESS (BY INDEX ROWID) OF 'PS_JOB' (Cost=3 Card=1 Bytes=30)
105 104 INDEX (RANGE SCAN) OF 'PSAJOB' (NON-UNIQUE) (Cost=2 Card=1)
106 105 SORT (AGGREGATE)
107 106 INDEX (RANGE SCAN) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=8 Bytes=128)
108 105 SORT (AGGREGATE)
109 108 INDEX (RANGE SCAN) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=1 Bytes=19)
110 98 INDEX (RANGE SCAN) OF 'PS_POSITION_DATA' (UNIQUE) (Cost=1 Card=1)
111 3 TABLE ACCESS (BY INDEX ROWID) OF 'PS_PERSONAL_DATA'(Cost=1 Card=1 Bytes=25)
112 111 INDEX (UNIQUE SCAN) OF 'PS_PERSONAL_DATA' (UNIQUE)
113 2 INDEX (RANGE SCAN) OF 'PS_LNT_ASN_SKL_TBL' (UNIQUE) (Cost=1 Card=10076 Bytes=80608)
Statistics
70 recursive calls
0 db block gets
1186931 consistent gets
5660 physical reads
60 redo size
462 bytes sent via SQL*Net to client
373 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
2 sorts (memory)
0 sorts (disk)
0 rows processedMy thoughts for this is:
1. NLJ high cost -- rewrite inner sub-query
2. sort is done for each join for max function every time so, therefore try use use sort merge hint
3. h alias has been referenced twice for table name.
PLEASE TELL ME WHAT TO DO IF I AM ORACLE DBA.
Thanks in advance.
Edited by: user2060331 on Mar 25, 2010 9:17 AM
Edited by: user2060331 on Mar 25, 2010 9:21 AM
Edited by: user2060331 on Mar 25, 2010 9:32 AM
Edited by: user2060331 on Mar 25, 2010 9:47 AMNo it's not. You should see indentations for each level of the explain plan. You've lost all of it. It should look like this (not your query):
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost | Inst |IN-OUT|
| 0 | SELECT STATEMENT | | 16116 | 2911K| 712 | | |
| 1 | FILTER | | | | | | |
| 2 | CONNECT BY WITH FILTERING | | | | | | |
| 3 | FILTER | | | | | | |
| 4 | COUNT | | | | | | |
| 5 | HASH JOIN RIGHT OUTER | | 16116 | 2911K| 712 | | |
| 6 | REMOTE | LSW_USR_GRP_XREF | 518 | 13986 | 4 | MYPROJ~ | R->S |
| 7 | HASH JOIN RIGHT OUTER | | 16116 | 2486K| 707 | | |
| 8 | REMOTE | LSW_USR_XREF | 222 | 2886 | 4 | MYPROJ~ | R->S |
| 9 | HASH JOIN RIGHT OUTER| | 16116 | 2282K| 702 | | |
| 10 | TABLE ACCESS FULL | MYPROJ_PROCESS_MAP | 176 | 4752 | 4 | | |
| 11 | HASH JOIN OUTER | | 16116 | 1857K| 698 | | |
| 12 | TABLE ACCESS FULL | MYPROJ_MPPA | 16116 | 1243K| 71 | | |
| 13 | REMOTE | LSW_TASK | 80730 | 3074K| 625 | MYPROJ~ | R->S |
| 14 | HASH JOIN | | | | | | |
| 15 | CONNECT BY PUMP | | | | | | |
| 16 | COUNT | | | | | | |
| 17 | HASH JOIN RIGHT OUTER | | 16116 | 2911K| 712 | | |
| 18 | REMOTE | LSW_USR_GRP_XREF | 518 | 13986 | 4 | MYPROJ~ | R->S |
| 19 | HASH JOIN RIGHT OUTER | | 16116 | 2486K| 707 | | |
| 20 | REMOTE | LSW_USR_XREF | 222 | 2886 | 4 | MYPROJ~ | R->S |
| 21 | HASH JOIN RIGHT OUTER| | 16116 | 2282K| 702 | | |
| 22 | TABLE ACCESS FULL | MYPROJ_PROCESS_MAP | 176 | 4752 | 4 | | |
| 23 | HASH JOIN OUTER | | 16116 | 1857K| 698 | | |
| 24 | TABLE ACCESS FULL | MYPROJ_MPPA | 16116 | 1243K| 71 | | |
| 25 | REMOTE | LSW_TASK | 80730 | 3074K| 625 | MYPROJ~ | R->S |
--------------------------------------------------------------------------------------------------- -
ADF 11g - Query Component - How to set default values for search criteria
I have defined a VO with named query (with 2 search criteria). I created a page and drop a query with table. It works just fine until this point. My requirement is to set a default values for the two search criteria. For example, I have release and category criteria where they are set to use a drop down. I would like to default the values for the drop down when the page is shown up the first time and query the result right away. Is there a way declaratively or I have to create a custom query?
Thanks.I figured this out. Thanks.
Maybe you are looking for
-
Not able to print TO in background from migo
hi i am posting a material document from MIGO,it will create Auto TO and have to print. but my problem is it is creating Auto TO but it is not printing and when i check the spool status is awaiting.i check the queue and is clear.i can print the TO fr
-
I remember I used to have it because I used to use a lot, but now is gone.
-
Exception in Service Mapping Tool
Hello, I'm trying to use the Service Mapping Tool, but run into the exception "Parameter CH_CHANGE was not transferred" when executing the mapping. Does anyone have any insight why this might be? Regards Mattias
-
Error while installing Exchange 2013 readiness check
Hello ! i've encountered a problam during the installation of the Exchange Server 2013 on the Readiness Check, please, see below the following error: Error: The following error was generated when "$error.Clear(); if (Get-Service MpsSvc* |
-
AE CC 2014 audio preview speed up error... "chipmunking" randomly
I"ve been having an issue where the audio during a full RAM preview with video or even if it's just audio preview (no visual) will play sped up. Sometimes it will speed up after having previewed correctly once, but every subsequent time will result i