Tuning SQL request
HelloThe goal for the following statement is so that it can be created as a point of view, but it takes 45 minutes minimum to complete. He returned about 200 000 lines and will gradually increase approximately 1,000 lines a day. Please bear with me, I couldn't get the output autotrace and dbms_xplan.display_cursor, because it takes ages to run. I've included output from v$ sql sql instead, hope this helps.
Database version: 10.2.0.1
Here are the coded sql statement:
select tbl_4.col1,
tbl_1.col2,
tbl_1.col3,
tbl_1.col4,
tbl_5.col5,
tbl_1.col6,
tbl_1.col7,
tbl_2.col8,
tbl_2.col9,
tbl_2.col10,
tbl_2.col11,
tbl_2.col12,
tbl_3.col13,
substr(tbl_6.col14, 1, 2),
substr(tbl_6.col14, 4, 10),
a.number_of_sales,
decode (tbl_1.year, 99, 1999,
00, 2000,
98,1998),
NVL2(tbl_7.col16, 'Yes', 'None'),
NVL2(tbl_8.col17, tbl_8.col1, 'N/A'),
NVL2(tbl_8.col18, tbl_8.col1, 'N'),
NVL2(tbl_8.col19, tbl_8.col1, 'N'),
NVL2(tbl_8.col20, tbl_8.col1, 'N'),
tbl_6.col21
from tbl_1
join tbl_2 on (tbl_2.guid = tbl_1.guid)
join tbl_3 on (tbl_3.guid = tbl_1.guid)
join tbl_5 on (tbl_5.guid = tbl_1.guid)
join tbl_6 on (tbl_6.guid = tbl_1.guid)
join (select prod, number_of_sales
from tbl_1
where prod IN
(select guid
from tbl_6)
MODEL
PARTITION BY (country)
DIMENSION BY (prod, year)
MEASURES (prod as number_of_sales)
IGNORE NAV
UNIQUE DIMENSION
RULES UPDATE SEQUENTIAL ORDER
(
number_of_sales[ANY, ANY] =
CASE WHEN count(number_of_sales)[ANY, '1999'] > 0
THEN count(number_of_sales)[ANY, '1999']
ELSE (CASE WHEN count(number_of_sales)[ANY, '2000'] > 0
THEN count(number_of_sales)[ANY, '2000']
ELSE (CASE WHEN count(number_of_sales)[ANY, '1998'] > 0
THEN count(number_of_sales)[ANY, '1998']
ELSE 0
END)
END)
END
));a on (a.prod = tbl_1.prod)
left outer join tbl_7 on (tbl_7.guid = tbl_1.guid)
left outer join tbl_8 on (tbl_8.guid = tbl_1.guid)
left outer join tbl_4 on (tbl_4.col22 = tbl_1.col23);
Here is the output of the explain plan:PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Plan hash value: 2231252653
---------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
---------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 60357 | 29M| | 25428 (2)| 00:05:06 |
|* 1 | HASH JOIN RIGHT OUTER | | 60357 | 29M| | 25428 (2)| 00:05:06 |
| 2 | TABLE ACCESS FULL | TBL_8 | 727 | 53798 | | 6 (0)| 00:00:01 |
|* 3 | HASH JOIN RIGHT OUTER | | 60357 | 25M| | 25420 (2)| 00:05:06 |
| 4 | TABLE ACCESS FULL | TBL_4 | 102 | 7854 | | 3 (0)| 00:00:01 |
|* 5 | HASH JOIN | | 60357 | 20M| 17M| 25415 (2)| 00:05:05 |
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
|* 6 | HASH JOIN | | 60742 | 16M| 15M| 21282 (2)| 00:04:16 |
|* 7 | HASH JOIN | | 63196 | 15M| 14M| 19152 (2)| 00:03:50 |
|* 8 | HASH JOIN | | 66797 | 13M| 5696K| 16578 (2)| 00:03:19 |
| 9 | VIEW | | 176K| 3619K| | 6779 (2)| 00:01:22 |
| 10 | BUFFER SORT | | 176K| 15M| | | |
| 11 | SQL MODEL ORDERED | | 176K| 15M| | | |
|* 12 | HASH JOIN | | 176K| 15M| 6152K| 6779 (2)| 00:01:22 |
| 13 | INDEX FAST FULL SCAN| TBL_6_PK | 128K| 4643K| | 214 (2)| 00:00:03 |
| 14 | TABLE ACCESS FULL | TBL_1 | 466K| 25M| | 4701 (2)| 00:00:57 |
|* 15 | HASH JOIN RIGHT OUTER | | 176K| 32M| | 7814 (2)| 00:01:34 |
| 16 | TABLE ACCESS FULL | TBL_7 | 467 | 19614 | | 3 (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
|* 17 | HASH JOIN | | 176K| 25M| 7536K| 7808 (2)| 00:01:34 |
| 18 | TABLE ACCESS FULL | TBL_6 | 128K| 6023K| | 225 (3)| 00:00:03 |
| 19 | TABLE ACCESS FULL | TBL_1 | 466K| 44M| | 4701 (2)| 00:00:57 |
| 20 | TABLE ACCESS FULL | TBL_3 | 321K| 12M| | 1059 (3)| 00:00:13 |
| 21 | TABLE ACCESS FULL | TBL_5 | 326K| 12M| | 523 (3)| 00:00:07 |
| 22 | TABLE ACCESS FULL | TBL_2 | 337K| 22M| | 1919 (3)| 00:00:24 |
---------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
1 - access("TBL_8"."GUID"(+)="TBL_1"."GUID")
3 - access("TBL_4"."COL22"(+)="TBL_1"."COL23")
5 - access("TBL_2"."GUID"="TBL_1"."GUID")
6 - access("TBL_5"."GUID"="TBL_1"."GUID")
7 - access("TBL_3"."GUID"="TBL_1"."GUID")
8 - access("A"."PROD"="TBL_1"."PROD")
12 - access("GUID"="GUID")
15 - access("TBL_7"."GUID"(+)="TBL_1"."GUID")
17 - access("TBL_6"."GUID"="TBL_1"."GUID")
Here is the optimizer settings:NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.1
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
db_file_multiblock_read_count integer 16
db_block_size integer 8192
cursor_sharing string EXACT
SNAME PNAME PVAL1 PVAL2
-------------------- -------------------- ---------- --------------------
SYSSTATS_INFO STATUS COMPLETED
SYSSTATS_INFO DSTART 08-30-2005 15:04
SYSSTATS_INFO DSTOP 08-30-2005 15:04
SYSSTATS_INFO FLAGS 1
SYSSTATS_MAIN CPUSPEEDNW 484.974958
SYSSTATS_MAIN IOSEEKTIM 10
SYSSTATS_MAIN IOTFRSPEED 4096
SYSSTATS_MAIN SREADTIM
SYSSTATS_MAIN MREADTIM
SYSSTATS_MAIN CPUSPEED
SYSSTATS_MAIN MBRC
SNAME PNAME PVAL1 PVAL2
-------------------- -------------------- ---------- --------------------
SYSSTATS_MAIN MAXTHR
SYSSTATS_MAIN SLAVETHR
Here is the TKProf output:call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.48 0.52 10 48 192 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 4112 87.79 1099.84 3890789 61207 2 205504
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4114 88.28 1100.36 3890799 61255 194 205504
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 72
Rows Row Source Operation
------- ---------------------------------------------------
205504 HASH JOIN RIGHT OUTER (cr=61207 pr=3890789 pw=3336846 time=1099316224 us)
731 TABLE ACCESS FULL TBL_8 (cr=23 pr=11 pw=0 time=11508 us)
205504 HASH JOIN RIGHT OUTER (cr=61184 pr=3890778 pw=3336846 time=1098446711 us)
102 TABLE ACCESS FULL TBL_4 (cr=7 pr=6 pw=0 time=10685 us)
205504 HASH JOIN (cr=61177 pr=3890772 pw=3336846 time=1097406100 us)
205504 HASH JOIN (cr=52309 pr=3876731 pw=3331582 time=1092251311 us)
205504 HASH JOIN (cr=49818 pr=3872092 pw=3327095 time=1088296724 us)
205504 HASH JOIN (cr=44805 pr=3862788 pw=3322741 time=1083430636 us)
205504 VIEW (cr=22340 pr=3824447 pw=3312710 time=1064542304 us)
205504 BUFFER SORT (cr=22340 pr=3824447 pw=3312710 time=1064131291 us)
205504 SQL MODEL ORDERED (cr=22340 pr=3823920 pw=3312183 time=79100422 us)
205504 HASH JOIN (cr=22340 pr=24845 pw=3829 time=22189967 us)
135074 INDEX FAST FULL SCAN TBL_6_PK (cr=1011 pr=869 pw=0 time=955438 us)(object id 103575)
469544 TABLE ACCESS FULL TBL_1 (cr=21329 pr=17067 pw=0 time=12229819 us)
205504 HASH JOIN RIGHT OUTER (cr=22465 pr=34519 pw=6209 time=18445327 us)
497 TABLE ACCESS FULL TBL_7 (cr=7 pr=3 pw=0 time=15547 us)
205504 HASH JOIN (cr=22458 pr=34516 pw=6209 time=17560031 us)
135074 TABLE ACCESS FULL TBL_6 (cr=1082 pr=1059 pw=0 time=157502 us)
469544 TABLE ACCESS FULL TBL_1 (cr=21376 pr=16734 pw=0 time=11749176 us)
341927 TABLE ACCESS FULL TBL_3 (cr=5013 pr=4950 pw=0 time=2080124 us)
341935 TABLE ACCESS FULL TBL_5 (cr=2491 pr=152 pw=0 time=5129098 us)
341932 TABLE ACCESS FULL TBL_2 (cr=8868 pr=8777 pw=0 time=3436425 us)
Here is the output from v$ sqlSQL_TEXT select tbl_4…
SQL_FULLTEXT
SQL_ID bh7z3jzt6vw06
SHARABLE_MEM 66824
PERSISTENT_MEM 25756
RUNTIME_MEM 23808
SORTS 1
LOADED_VERSIONS 1
OPEN_VERSIONS 1
USERS_OPENING 1
FETCHES 1
EXECUTIONS 1
PX_SERVERS_EXECUTIONS 0
END_OF_FETCH_COUNT 0
USERS_EXECUTING 1
LOADS 1
FIRST_LOAD_TIME 2009-08-14/15:59:08
INVALIDATIONS 0
PARSE_CALLS 1
DISK_READS 3905090
DIRECT_WRITES 3340053
BUFFER_GETS 62290
APPLICATION_WAIT_TIME 0
CONCURRENCY_WAIT_TIME 0
CLUSTER_WAIT_TIME 0
USER_IO_WAIT_TIME 1042926858
PLSQL_EXEC_TIME 0
JAVA_EXEC_TIME 0
ROWS_PROCESSED 50
COMMAND_TYPE 3
OPTIMIZER_MODE ALL_ROWS
OPTIMIZER_COST 25428
OPTIMIZER_ENV E289FB.......
OPTIMIZER_ENV_HASH_VALUE 1151412318
PARSING_USER_ID 72
PARSING_SCHEMA_ID 72
PARSING_SCHEMA_NAME DATA
KEPT_VERSIONS 0
ADDRESS 569F083C
TYPE_CHK_HEAP 00
HASH_VALUE 4067291142
OLD_HASH_VALUE 1777942244
PLAN_HASH_VALUE 2231252653
CHILD_NUMBER 0
SERVICE SYS$USERS
SERVICE_HASH 0
MODULE SQL Developer
MODULE_HASH 0
ACTION
ACTION_HASH 0
SERIALIZABLE_ABORTS 0
OUTLINE_CATEGORY
CPU_TIME 81093819
ELAPSED_TIME 1122285962
OUTLINE_SID
CHILD_ADDRESS 52541620
SQLTYPE 6
REMOTE N
OBJECT_STATUS VALID
LITERAL_HASH_VALUE 0
LAST_LOAD_TIME 2009-08-14/15:59:08
IS_OBSOLETE N
CHILD_LATCH 3
SQL_PROFILE
PROGRAM_ID 101200
PROGRAM_LINE# 2
EXACT_MATCHING_SIGNATURE 4.3484E+18
FORCE_MATCHING_SIGNATURE 1.5863E+19
LAST_ACTIVE_TIME 14-AUG-09
BIND_DATA
There is a large gap between the time cpu and elapsed time. So a lot of time - more than 1000 seconds of 1100 seconds in total - were spent waiting. Please repeat track/tkprof step you took, but this time include the record of the expectations. You can do, for example, by launching:
alter session set events '10046 trace name context forever, level 8'
I think for now, is that your PGA is undersized for this query, because the time is especially dedicated to step "BUFFER FATE." If the report of tkprof including wait, reveals a lot of 'direct path read temp' and 'direct path write temp', then we know for sure.
Kind regards
Rob.
Tags: Database
Similar Questions
-
Tuning sql of a product to the seller without changing the sql statement
Hello
We have a product of the provider that generates the SQL statement. For a query, we get the answer in 15 seconds. But users are asking if we can bring it back to 5 seconds. Limitation is the query can not be changed. He used about 10 to 12 tables and bit complex query.
What kind of options could be evaluated if we are to improve the performance of a query (not sure if she could never be reduced to 5 seconds)
without making any change to the query.
Database Version: Oracle 10.2.0.4
Thank you
DelphineHello
http://www.Oracle-base.com/articles/10G/AutomaticSQLTuning10g.php
your software is enterprise or standard?
Tuning Pack & pack diagnosis are extra cost option with the standard edition.
& the useful note * automatic SQL Tuning - SQL [271196.1 ID] profiles *.
http://www.Oracle.com/us/corporate/pricing/technology-price-list-070617.PDF
Thank you
Published by: CKPT November 5, 2010 11:12
-
Oracle Database 10 g Enterprise Edition release 10.2.0.3.0 - 64bi
PL/SQL version 10.2.0.3.0 - Production
CORE Production 10.2.0.3.0
AMT for IBM/AIX RISC System/6000: Version 10.2.0.3.0 - production
NLSRTL Version 10.2.0.3.0 - Production
I have a request involoved sweep the entire table with 5 billion lines and its execution plan indicates that it uses almost 40 tablespace temp G takes a lot of time. I am trying to tune by the biggest table based on a single partitioning column and run this query based on partitioned column at once does not work. This table is also used by other queries, I'm not sure whether paritioning of this table is wrong another query?
Thanks in advance.PL see these discussions on how to post a request for Setup:
HOW to: Validate a query of SQL statement tuning - model showing
When your query takes too long...
HTH
Srini -
Hello
I installed a new database and you can see that automatic SQL Tuning is by default enabled.
It's best practices and there is no end with SQL runtime performance downgrade?
Oracle 11.2.0.3 database
Also where in 12 c EM find all active SQL Profiler?
Concerning
933746Read the documentation
http://docs.Oracle.com/CD/B28359_01/server.111/b28274/sql_tune.htm -
Hi guys,.
There is an error when switching to SQL Tuning Tips Top SQL compared to expected.
the error is:
Normally this task should be done by SqlDeveloper, ain't it?ORA-13607: The specified task or object id sql_id_tuning_task_SD already exists
What can I do?
10 x FlorinHi Florin,
I'm sorry that I misinterpreted your question in my previous answer. Of course, you don't talk about setting SQL as run from a worksheet, but rather discovers reports | Reports of data dictionary. Administration of databases | Top of page SQL | Top of page SQL of Waits. You selected a specific line (SQL statement) of the top SQL grid waits, then tried to pass to the sql tuning tips of the pane tab below.
The sql_id_tuning_task_SD must have been deleted automatically at the end of the previous call to this tab somehow, it not deleted. Have test you this feature on two copies of the SQL Developer at the same time? Probably not.
Anyway, as noted above, use dbms_sqltune.drop_tuning_task to work around the problem.
Kind regards
Gary -
Tuning sql by using the xmltable() function.
Hi all
With Oracle 10g 10.2.0.1, Solaris 10
Under query very slow... for 25 k at all just 100 KB xml documents.
I tried to create indexes on this table... but in vain...SELECT HQ_FLAG , REGSTR_FLAG ADDRESS_STAMP , BUILDING , street_address , PO_BOX , CITY , STATE_REGION , POSTAL_CODE , country_code , a.ORG_ID FROM common.BID_XML_DATA a, xmltable( 'for $i in IntegrationBID/Organization return <Row OrgID="{$i/OrgID}">{ $i/OrgGeneralInformation/Address } </Row>' passing xml_data columns hq_flag varchar2(5) path 'Address/@HeadquartersFlag', regstr_flag varchar2(5) path 'Address/@RegisteredFlag', address_stamp varchar(10) path 'Address/@LastUpdated', building varchar(40) path 'Address/Building', street_address varchar(40) path 'Address/StreetAddress', po_box varchar(40) path 'Address/POBox', city varchar(40) path 'Address/City', state_region character(3) path 'Address/StateOrRegion', postal_code varchar(10) path 'Address/PostalCode', country_code character(3) path 'Address/Country/@Code', Org_ID NUMBER(19) path '@OrgID') b; SQL> desc common.BID_XML_DATA Name Null? Type ----------------------------------------------------------------------------------- -------- -------------------------------------------------------- XML_DATA XMLTYPE BID_INSERT_STAMP DATE RN NUMBER(5) ORG_ID NUMBER(19) -------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 8168 | 749K| 27 (0)| 00:00:01 | | 1 | MERGE JOIN CARTESIAN | | 8168 | 749K| 27 (0)| 00:00:01 | | 2 | TABLE ACCESS FULL | BID_XML_DATA | 1 | 92 | 3 (0)| 00:00:01 | | 3 | BUFFER SORT | | 8168 | 16336 | 24 (0)| 00:00:01 | | 4 | COLLECTION ITERATOR PICKLER FETCH| XMLSEQUENCEFROMXMLTYPE | | | | | --------------------------------------------------------------------------------------------------------------
Could someone help me in creating xmlindex... and also to grant this request.SQL> CREATE INDEX common.XML_DATA_IDX ON common.BID_XML_TABLE (xml_data) 2 INDEXTYPE IS XDB.XMLIndex PARAMETERS ('PATHS (INCLUDE (IntegrationBID/Organization/OrgID 3 4 IntegrationBID/Organization/OfficerInformation/Officer/ID 5 IntegrationBID/Organization/WebLinkInfo 6 IntegrationBID/Organization/FilingSpecificInformation/FilingInformation/CompanyID IntegrationBID/Organization/FilingSpecificInformation/FilingInformation/ContactInfo 7 8 IntegrationBID/Organization/FilingSpecificInformation/FilingInformation/Advisors/TransferAgent/Name 9 IntegrationBID/Organization/OfficerInformation/Officer/PersonInformation/Name 10 IntegrationBID/Organization/OfficerInformation/Officer/OfficerContacts 11 IntegrationBID/Organization/OfficerInformation/Officer/PersonInformation/EducationHistory/Education 12 IntegrationBID/Organization/OfficerInformation/Officer/PositionInformation/TenureDates 13 IntegrationBID/Organization/OfficerInformation/Officer/PositionInformation/Titles/Designation 14 IntegrationBID/Organization/OfficerInformation/Officer/PositionInformation/CommitteeMemberships/Committee IntegrationBID/Organization/OfficerInformation/Officer/SalaryInformation/CompensationPeriod 15 16 ) 17 NAMESPACE MAPPING 18 (xmlns="http://www.schemas.thomsonreuters.com/IntBID03") 19 ) 20 PATH TABLE BID_XML_path_table 21 PATH ID INDEX BID_XML_pathid_ix 22 ORDER KEY INDEX BID_XML_orderkey_ix 23 ASYNC (SYNC ALWAYS) STALE (FALSE) 24 '); CREATE INDEX common.XML_DATA_IDX ON common.BID_XML_TABLE (xml_data) * ERROR at line 1: ORA-29896: Length of PARAMETER string longer than 1000 characters SQL> CREATE INDEX common.BID_XML_DATA_IDX ON common.BID_XML_DATA (xml_data) 2 INDEXTYPE IS XDB.XMLIndex PARAMETERS ('PATHS (INCLUDE (IntegrationBID/Organization/OrgID 3 4 IntegrationBID/Organization/OfficerInformation/Officer/ID 5 IntegrationBID/Organization/WebLinkInfo 6 IntegrationBID/Organization/FilingSpecificInformation/FilingInformation/CompanyID ) 7 8 NAMESPACE MAPPING 9 (xmlns="http://www.schemas.thomsonreuters.com/IntBID03") ) 10 11 PATH TABLE BID_XML_path_table 12 PATH ID INDEX BID_XML_pathid_ix 13 ORDER KEY INDEX BID_XML_orderkey_ix 14 ASYNC (SYNC ALWAYS) STALE (FALSE) 15 '); CREATE INDEX common.BID_XML_DATA_IDX ON common.BID_XML_DATA (xml_data) * ERROR at line 1: ORA-29958: fatal error occurred in the execution of ODCIINDEXCREATE routine ORA-30955: internal event to enable value index creation
-YasserYou have 2 options for this make effective and efficient:
1) move to 11gRx and change the XMLTYPE (based CLOB) column as XML binary XMLType
(2) in 10 g, the only option to make this work is to change the CLOB, XMLType column base in a relational object XMLType one.HTH
M.
-
Hello
Version 10203
Please look at the results of the created task of tuning.
The task has been created, but did not return any results.
Who is oracle average cant advice, or maybe I made mistakes?
SQL > declare
l_sql_id 2 v$session.prev_sql_id%type;
3 l_tuning_task varchar2 (30);
4 start
l_sql_id 5: = "bf8wy6bhr6nak";
6 l_tuning_task: = dbms_sqltune.create_tuning_task (sql_id = > l_sql_id);
7 dbms_sqltune.execute_tuning_task (l_tuning_task);
8 dbms_output.put_line (l_tuning_task);
9 end;
10.
TASK_32137
PL/SQL procedure successfully completed.
SQL >
SQL > fixed line 300
SQL > select dbms_sqltune.report_tuning_task ('TASK_32137') of double;
DBMS_SQLTUNE. REPORT_TUNING_TASK ('TASK_32137')
--------------------------------------------------------------------------------
GENERAL INFORMATION SECTION
----------------------------------------------------
SQL >
Thank youHi user546852,
dbms_sqltune.report_tuning_task returns a CLOB.
Try the LONG parameter to 1000000 in your session:
SQL> set long 1000000
Greetings - Don Lewis
-
Hi all
The application team uses under request and asked for recommendation for listening to this query.
The concern was
(1) how to avoid the query select sup as a query of subselects 3 is here which may degrade the performance of the query.
(2) in any case to avoid using the JOBBERDETAILS 5 times in NVL function.
SELECT "0". SM. SITE_ID AS "SD_SITE_NUMBER."
SA. ADDR_L1 AS "SD_SITE_ADDRESS."
SA. CITY_NAME AS "SD_SITE_CITY."
SA. STATE_AC AS "SD_SITE_STATE."
SUBSTR (SA. ZIP_CD, 0, 5) AS "SD_SITE_ZIP."
DECODE (LENGTH (TRIM (SA. ZIP_CD)), 5, '0000', SUBSTR (SA. ZIP_CD, 6, 4)) AS "SD_SITE_ZIP4."
SM. SITE_NAME AS "SD_NAME."
NVL ((SELECT SM. AM_SITE DOJ_NAME. B JOBBER_BASE WHERE B.SITE_ID = SM. (SITE_ID),' ') AS "SD_NAME2."
NVL (AM_SITE. JOBBERDETAILS (SA. (SITE_ID, 'OWNER_ADDRESS'),' ') AS "SD_MAILING_ADDRESS."
NVL (AM_SITE. JOBBERDETAILS (SA. (SITE_ID, 'OWNER_CITY'),' ') AS "SD_MAILING_CITY."
NVL (AM_SITE. JOBBERDETAILS (SA. (SITE_ID, 'OWNER_STATE'),' ') AS "SD_MAILING_STATE."
NVL (AM_SITE. JOBBERDETAILS (SA. (SITE_ID, 'OWNER_ZIP_CODE'),' ') AS "SD_MAILING_ZIP_CODE."
NVL (AM_SITE. JOBBERDETAILS (SA. (SITE_ID, 'OWNER_PHONE'), "0000000000") AS "SD_PHONE_NUMBER."
NVL ((SELECT ST. PHONE FROM AM_SITE. WHERE THE ST. SITE_TELEPHONE ST. SITE_ID = SM. SITE_ID AND SUPERIOR (ST. PHONE) = 'P'), "0000000000") AS "SITE_PHONE_NUMBER."
NVL ((SELECT B.J_SITE_ID FROM AM_SITE. B JOBBER_BASE WHERE B.SITE_ID = SM. SITE_ID AND AM_SITE. GET_COT (SM. (SITE_ID) = 'J'), "") AS "SD_JOBBER_NUMBER."
"1" AS "BANK_LEVEL."
"E' AS"AGENT. "
SM. DEFERRED_IND AS "DEFFERED_SETTLEMENT_INDICATOR."
SM. EXCESSIVE_CHAGK_IND AS "EXCESSIVE_CHARGEBACK_INDICATOR."
NVL (AM_SITE. GET_COT (SM. (SITE_ID),' ') AS "CHANNEL_OF_TRADE."
DECODE (AM_SITE. GET_COT (SM. ("" "" "SITE_ID),'d", '02', 'J', '11', ' C ', '23', "R", '21', 'N ' 21', ' Z ',' 21', 'NA') AS 'OUTLET_CODE '.
OF AM_SITE. SM, AM_SITE SITE_MSTR. SITE_ADDR SA
WHERE SM. SITE_ID = SA. SITE_ID AND SUPERIOR (SA. ADDR_TYPE) = 'P' AND SM. MOP_CD IS NOT NULL
Can someone please help me in setting this query.
Thanks in advanceFollower of the Oracle says:
Hi allThe application team uses under request and asked for recommendation for listening to this query.
The concern was(1) how to avoid the query select sup as a query of subselects 3 is here which may degrade the performance of the query.
Use outer joins instead of scalar subqueries. See for example the recent discussion of Tom Kyte: http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:1594885400346999596
(2) in any case to avoid using the JOBBERDETAILS 5 times in NVL function.
You need to know what the function does, and replace it with a simple corresponding SQL expression. Most of the time these functions search the recursive SQL which can be very expensive. Although the functional separation is better in terms of encapsulation/maintainability ordinary SQL approach gives better performance if you have a result of great value.
Have you checked that above two points are key issues of this query? By work without the function calls and scalar subqueries, you can check if it performs much better. If this isn't the case, you will need to investigate on what is still the main culprit.
Kind regards
RandolfOracle related blog stuff:
http://Oracle-Randolf.blogspot.com/SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676 /.
http://sourceforge.NET/projects/SQLT-pp/ -
Tuning sql (where order clauses)
Hello
This request is really slow, because it calls the function f to each line (table1 and table2 may have more than 10000 lines)
SELECT * FROM table1 t1 inner join tabl2 t2.............. WHERE where_clause_1 AND where_clause_2 AND f(t1.a, t2.a) = 'Y'
Returns 20 lines
Howerver, this query is much faster
SELECT * FROM table1 t1 inner join tabl2 t2.............. WHERE where_clause_1 AND where_clause_2 -- AND f(t1.a, t2.a) = 'Y'
Returns 24 ranks
I try that, but it is too slow:
SELECT * FROM ( SELECT ... FROM table1 t1 inner join tabl2 t2.............. WHERE where_clause_1 AND where_clause_2 ) WHERE f(t1_a, t2_a) = 'Y'
I would like to SELECT by where_clause_1 filter then where_clause_2 and finally the function call.
How can I do?
Thank you!
- SELECT * FROM)
- SELECT / * + NO_MERGE * /... THE T1 from table1 inner join t2 tabl2...
- WHERE where_clause_1
- AND where_clause_2
- )
- WHERE f (t1_a, t2_a) = 'Y '.
Indicates tips NO_MERGE optimizer outer query not combine and query the view of inline in a unique.
-
Tuning sql insert that inserts 1 million lines makes a full table scan
Hi Experts,
I'm on Oracle 11.2.0.3 on Linux. I have a sql that inserts data into a table of History/Archives of a table main application based on the date. The application table has 3 million lines. and all the lines that are more then 6 months old must go in a table of History/Archives. This was decided recently, and we have 1 million rows that meet this criterion. This insertion in table archive takes about 3 minutes. Plan of the explain command shows a full table scan on the main Board - which is the right thing, because we are pulling 1 million rows in the main table in the history table.
My question is that, is it possible that I can do this sql go faster?
Here's the query plan (I changed the names of table etc.)
INSERT INTO EMP_ARCH SELECT * FROM EMP M where HIRE_date < (sysdate - :v_num_days); call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 2 0.00 0.00 0 0 0 0 Execute 2 96.22 165.59 92266 147180 8529323 1441230 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 96.22 165.59 92266 147180 8529323 1441230 Misses in library cache during parse: 1 Misses in library cache during execute: 1 Optimizer mode: FIRST_ROWS Parsing user id: 166 Rows Row Source Operation ------- --------------------------------------------------- 1441401 TABLE ACCESS FULL EMP (cr=52900 pr=52885 pw=0 time=21189581 us)
I heard that there is a way to use opt_param tip to increase the multiblock read County but did not work for me... I will be grateful for suggestions on this. can collections and this changing in pl/sql also make it faster?
Thank you
OrauserN
(1) create an index on hire_date
(2) tip 'additional' use in the 'select' query '
(3) run ' alter session parallel DML'; before you run the entire statement
-
Tuning SQL - do not understand the plan of the explain command.
Hi all
I use 11g R2 and I have 2 questions about the setting of a query.
My relevant parameters for the optimizer are:BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production PL/SQL Release 11.2.0.3.0 - Production CORE 11.2.0.3.0 Production TNS for 64-bit Windows: Version 11.2.0.3.0 - Production NLSRTL Version 11.2.0.3.0 - Production
The query I want to run is quite simple. It returns a few exceptions with a filter.NAME TYPE VALUE ------------------------------------ ----------- ----------------------- -- optimizer_capture_sql_plan_baselines boolean FALSE optimizer_dynamic_sampling integer 2 optimizer_features_enable string 11.2.0.3 optimizer_index_caching integer 0 optimizer_index_cost_adj integer 100 optimizer_mode string ALL_ROWS optimizer_secure_view_merging boolean TRUE optimizer_use_invisible_indexes boolean FALSE optimizer_use_pending_statistics boolean FALSE optimizer_use_sql_plan_baselines boolean TRUE
The execution plan is the following:SELECT ERO.DVC_EVT_ID, E.DVC_EVT_DTTM FROM D1_DVC_EVT E, D1_DVC_EVT_REL_OBJ ERO WHERE ERO.MAINT_OBJ_CD = 'D1-DEVICE' AND ERO.PK_VALUE1 = :H1 AND ERO.DVC_EVT_ID = E.DVC_EVT_ID AND E.DVC_EVT_TYPE_CD IN ('END-GSMLOWLEVEL-EXCP-SEV-1', 'STR-GSMLOWLEVEL-EXCP-SEV-1') ORDER BY E.DVC_EVT_DTTM DESC;
So, as you can see, rank 8, I have a TABLE ACCESS BY GLOBAL INDEX ROWID. But what I am failling to see is how Oracle display an ACCESS BY GLOBAL INDEX ROWID TABLE without using any index. As the thought that Oracle has always been a ROWID due to an index.Plan hash value: 3627978539 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| Pstart| Pstop | A-Rows | A-Time | Buffers | Reads | OMem | 1Mem | Used-Mem | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | | | 7131 (100)| | | 1181 |00:00:17.17 | 8627 | 2978 | | | | | 1 | SORT ORDER BY | | 1 | 3137 | 275K| 7131 (1)| | | 1181 |00:00:17.17 | 8627 | 2978 | 80896 | 80896 |71680 (0)| | 2 | NESTED LOOPS | | 1 | | | | | | 1181 |00:00:17.16 | 8627 | 2978 | | | | | 3 | NESTED LOOPS | | 1 | 3137 | 275K| 7130 (1)| | | 2058 |00:00:08.09 | 6709 | 1376 | | | | | 4 | TABLE ACCESS BY INDEX ROWID | D1_DVC_EVT_REL_OBJ | 1 | 3137 | 125K| 845 (1)| | | 2058 |00:00:04.37 | 820 | 799 | | | | |* 5 | INDEX RANGE SCAN | D1T404S0 | 1 | 3137 | | 42 (0)| | | 2058 |00:00:00.08 | 27 | 23 | | | | | 6 | PARTITION RANGE ITERATOR | | 2058 | 1 | | 1 (0)| KEY | KEY | 2058 |00:00:03.69 | 5889 | 577 | | | | |* 7 | INDEX UNIQUE SCAN | D1T400P0 | 2058 | 1 | | 1 (0)| KEY | KEY | 2058 |00:00:03.66 | 5889 | 577 | | | | |* 8 | TABLE ACCESS BY GLOBAL INDEX ROWID| D1_DVC_EVT | 2058 | 1 | 49 | 2 (0)| ROWID | ROWID | 1181 |00:00:09.05 | 1918 | 1602 | | | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Peeked Binds (identified by position): -------------------------------------- 1 - (VARCHAR2(30), CSID=178): '271792300706' Predicate Information (identified by operation id): --------------------------------------------------- 5 - access("ERO"."PK_VALUE1"=:H1 AND "ERO"."MAINT_OBJ_CD"='D1-DEVICE') filter("ERO"."MAINT_OBJ_CD"='D1-DEVICE') 7 - access("ERO"."DVC_EVT_ID"="E"."DVC_EVT_ID") 8 - filter(("E"."DVC_EVT_TYPE_CD"='END-GSMLOWLEVEL-EXCP-SEV-1' OR "E"."DVC_EVT_TYPE_CD"='STR-GSMLOWLEVEL-EXCP-SEV-1'))
I also have an index on the DVC_EVT_TYPE_CD column in my table (line 8 of the predicate information section)
And finally, what would be your suggestions to improve the performance of this query...
Thank you very much.If I read content (RowSource) statistical information and plan properly, then access the table in step 4 on D1_DVC_EVT_REL_OBJ needs dry 4.37 and accesses 820 buffers. If you had an index D1_DVC_EVT_REL_OBJ (MAINT_OBJ_CD, PK_VALUE1, DVC_EVT_ID) I guess this table access could be avoided. To avoid the access of the table on D1_DVC_EVT an index on D1_DVC_EVT (DVC_EVT_ID, DVC_EVT_TYPE_CD, DVC_EVT_DTTM) should be sufficient.
I think that these indices would improve the performance of the query, but of course, they would have a negative impact on the performance of DML on the table and they could influence other queries on the table.
-
Hello
Im a dba.
The developer asked me to help resolve its sql query. Its quite a query complex and has many joins of tables.
It is the duty of a dba to tune the sqlquery? How can I suggest or modify the query for optimal performance? When I myself can't understand :(
Is to explain the way forward plan?
Can you suggest any solution please.
Thank you very much
Published by: 843228 on April 5, 2011 02:5810g and 11g offer better/improved/different alternatives to explain the plan and TKPROF but yes the basic principles of interpretation of EXPLAIN PLAN and TKPROF remain the same between different versions.
-
Hello
I need some General (I can't provide you with an implementation plan) tips for setting this statement running in mode CBO 9i:
SELECT TAB_C1.CLIENT_NR, TAB_C1.DD_NR, last_day(trunc(TAB_C1.BELEGDAT)), 0, TAB_C2.VALUE_DIM , nvl(SUM(DECODE(TAB_A.FOLGBU || TAB_A.ZUABNEUT,'0A',0,'1A',0,'0Z',1,'1Z',0) * TAB_C2.VALUE),0) , nvl(SUM(DECODE(TAB_A.FOLGBU || TAB_A.ZUABNEUT,'0A',1,'1A',0,'0Z',0,'1Z',0) * TAB_C2.VALUE),0) , nvl(SUM(DECODE(TAB_A.FOLGBU || TAB_A.ZUABNEUT,'0A',0,'1A',0,'0Z',0,'1Z',1) * TAB_C2.VALUE),0) , nvl(SUM(DECODE(TAB_A.FOLGBU || TAB_A.ZUABNEUT,'0A',0,'1A',1,'0Z',0,'1Z',0) * TAB_C2.VALUE),0) , 0 ,max(TAB_C1.ROWSEQ * 1000) + TAB_C2.BLENDTYPE * 100 + TAB_C2.VALUE_DIM FROM TAB_C1, TAB_A, TAB_C2, TAB_C3, TAB_B WHERE TAB_C1.ACC_TYPE = 'N' AND TAB_C1.CANCEL = 0 AND TAB_A.CLIENT_NR = TAB_C1.CLIENT_NR AND TAB_A.ACC_MODE = TAB_C1.ACC_MODE AND TAB_C3.CLIENT_NR = TAB_C1.CLIENT_NR AND TAB_C3.ACC_TYPE = TAB_C1.ACC_TYPE AND TAB_C3.ACC_NR = TAB_C1.ACC_NR AND TAB_C3.POS = TAB_C1.POS AND TAB_C3.ACC_DAT = TAB_C1.ACC_DAT AND TAB_C2.CLIENT_NR = TAB_C1.CLIENT_NR AND TAB_C2.ACC_TYPE = TAB_C1.ACC_TYPE AND TAB_C2.ACC_NR = TAB_C1.ACC_NR AND TAB_C2.POS = TAB_C1.POS AND TAB_C2.ACC_DAT = TAB_C1.ACC_DAT AND TAB_B.CLIENT_NR = TAB_C2.CLIENT_NR AND TAB_B.AMOUNT_KEY = TAB_C2.VALUE_DIM AND TAB_B.AMOUNT_TYPE = 0 GROUP BY TAB_C1.CLIENT_NR, releasetype, releaseid, releasegrp, releaseseq, last_day(trunc(TAB_C1.BELEGDAT)), blendtype, VALUE_DIM;
In my opinion, I should try to avoid function calls (nvl (sum...), but I don't ' have an idea how to achieve this in the best way.) Maybe you can give me some advice to fix this or tell me other options to improve performance. The view is used to populate a table.Table Rows PK TAB_A 300 CLIENT_NR, ACC_MODE TAB_B 600 CLIENT_NR, AMOUNT_KEY TAB_C1 200.000 CLIENT_NR, ACC_TYPE, ACC_NR, POS, ACC_DAT TAB_C2 1 Mio. CLIENT_NR, ACC_TYPE, ACC_NR, POS, ACC_DAT, COL_BP, VALUE_DIM, COL_BT TAB_C3 350.000 CLIENT_NR, ACC_TYPE, ACC_NR, POS, ACC_DAT, COL_RI, COL_RT, COL_RG, COL_RS, COL_RL
Thanks in advance
Kind regards
MatthiasI'd be really surprised if change anything in the select list would improve performance much. Integrated Oracle features most of the time about as fast as the selection of the column without using a function.
I have to focus my efforts on her go and where parts, which is the part that causes all i/o, which is generally the most expensive and time-consuming part of the query. Without looking too close to your request, and without knowing anything about your data, I note that tab_b and tab_c3 are not used in your selection list, and only tab_b has a selective predicate against it. Are you sure have need of these two tables?
Can you add more selective predicates against some or all tables without changing the query results? For example, only the tab_b.amount_type = 0 implies something of perhaps a range of dates or the range of accounts in the other tables.
You say that
restrictions:
TAB_C1. CANCEL = 0
TAB_B.AMOUNT_TYPE = 0a very low selectivity for indexing one of these columns seems to be not not very useful
but you also have a predicate on TAB_C1. ACC_TYPE = ' N AND TAB_C1. CANCEL = 0. This combination is more selective?
The list is long, but as others have said, without more information, we are only guessing.
John
-
SQL Tuning sets and SQL Tuning Advisor.
Hello
We run oracle11g r2 where under win server 2008 R2.
How can I find out when Tuning SQL and SQL Tuning games advisors are enabled in my database.
Is Oracle11g has default setting YES for this tuning packs
Thank you
It seems you found somone activated of sets and the setting of advisers. as others have said, theyre part of the D & T and theyre always there but only, you become eligible for a permit after that you use. This will tell you the first time they have been used if at all, the key here for you field be FIRST_USAGE_DATE that must be completed only if detected_usages > 0
fixed lines 180
Col name format a30
SELECT name, version, detected_usages, FIRST_USAGE_DATE, last_usage_date
of DBA_FEATURE_USAGE_STATISTICS
where upper (NAME) like '% % TUNING '.
-
List of the SQL tuning sets without OEM
Hello.
I want to know what table is used to store the SQL tuning games/SQL tuning set names. I know that I can easily find the SQL tuning set OEM list, but I want to know about table/dynamic views.
I Googled it but not able to find the table that stores the sql tuning set of tables.
Thank you.
B. Dave
Try different words in google, I used and had to be included... in google...
the value SQL tuning oracle dictionary tables
- Information Advisor views, such as
DBA_ADVISOR_TASKS
,DBA_ADVISOR_EXECUTIONS
,DBA_ADVISOR_FINDINGS
,DBA_ADVISOR_RECOMMENDATIONS
, andDBA_ADVISOR_RATIONALE
views. - SQL tuning views of information, such as
DBA_SQLTUNE_STATISTICS
,DBA_SQLTUNE_BINDS
, andDBA_SQLTUNE_PLANS
views. - SQL Tuning Set views, such as
DBA_SQLSET
,DBA_SQLSET_BINDS
,DBA_SQLSET_STATEMENTS
, andDBA_SQLSET_REFERENCES
views. - Information about captured execution plans for statements in SQL Tuning sets are displayed in the
DBA_SQLSET_PLANS
andUSER_SQLSET_PLANS
views. - SQL profile information is displayed in the
DBA_SQL_PROFILES
view. TheTYPE
parameter indicates if the SQL profile has been created manually by the SQL Setup Assistant (ifTYPE
=MANUAL
) or automatically by the auto tuning SQL (ifTYPE
=AUTO
). - Progress of enforcement Advisor information are displayed in the
V$ADVISOR_PROGRESS
view.
- Information Advisor views, such as
Maybe you are looking for
-
I did a film on I move This can be shared many ways - but no longer can you send to IDVD I lucky to have on my computer How in the world one take an i move around and burn these days? I shared it on i tunes- but y at - there no way to get a copy to p
-
But now back on blue was on cperia lounge
When I got my z5 I upgraded to gold on xperia lounge but I had a problem with my phone and had to reset my phone after I did my show xperia returned to blue I tried to connect with Google Facebook n, but it has not changed in gold I always my privile
-
Can I have 2 versions of Internet Explorer downloaded on my computer?
I upgraded to IE 9, but need version 8 for a website that I use for school. Is it possible to have two different versions, downloaded on Windows Vista? Like having Mozilla and Internet Explorer, or IE 9 replaced so will I download IE 8?
-
Maximum number of vNIC by blade
Is there a maximum number of vNIC tolerated by profile blade-server when you use 6248 FIs and blades B200 M4 with 1340 expander cards and the number of lower authorized vNIC with the same blade but without port expansion card?
-
Help with widget slider in CP8
Hello world!I am a user of a purchased slider widget control and I saw excerpts of how start with her, variables etc. Although it still seems I need extra help.I am creating an interaction where the student can drag the slider handle (with variable n