Same query, same dataset, same ddl setup, but wildly different explain plan
Hello o fountains of oracle knowledge!
We have a problem that caused us a full stop when rolling out a new version of our system to a customer and a whole Sunday to boot.
The scenario is as follows:
1. An previous version database schema
2. The current version database schema
3. A migration script to migrate the old schema to the new
So we perform the following migration:
1. Export the previous version database schema
2. Import into a new schema called schema_old
3. Create a new schema called schema_new
4. Run migration script which creates objects, copies data, creates indexes etc etc in schema_new
The migration runs fine in all environments (development, test and production)
In our development and test environments performance is stellar, on the customer production server the performance is terrible.
This using the exact same export file (from the production environment) and performing the exact same steps with the exact same migration script.
Database version is 10.2.0.1.0 EE on all databases. OS is Microsoft Windows Server 2003 EE SP2 on all servers.
The system is not in any sense under a heavy load (we have tested with no other load than ourselves).
Looking at the explain plan for a query that is run frequently and does not use bind variables we see wildly different explain plans.
The explain plan cost on our development and test servers is estimated to *7* for this query and there are no full table scans.
On the production server the cost is *8433* and there are two full table scans of which one is on the largest table.
We have tried to run analyse on all objects with very little effect. The plan changed very slightly, but still includes the two full table scans on the problem server and the cost is still the same.
All tables and indexes are identical (including storage options), created from the same migration script.
I am currently at loss for where to look? What can be causing this? I assume this could be caused by some parameter that is set on the server, but I don't know what to look for.
I would be very grateful for any pointers.
Thanks,
Håkon
Thank you for your answer.
We collected statistics only after we determined that the production server where not behaving according to expectations.
In this case we used TOAD and the tool within to collect statistics for all objects. We used 'Analyze' and 'Compute Statistics' options.
I am not an expert, so sorry if this is too naive an approach.
Here is the query:SELECT count(0)
FROM score_result sr, web_scorecard sc, product p
WHERE sr.score_final_decision like 'VENT%'
AND sc.CREDIT_APPLICATION_ID = sr.CREDIT_APPLICATION_ID
AND sc.application_complete='Y'
AND p.product = sc.web_product
AND p.inactive_product = '2' ;I use this as an example, but the problem exists for virtually all queries.
The output from the 'good' server:
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
| 0 | SELECT STATEMENT | | 1 | 39 | 7 (0)|
| 1 | SORT AGGREGATE | | 1 | 39 | |
| 2 | NESTED LOOPS | | 1 | 39 | 7 (0)|
| 3 | NESTED LOOPS | | 1 | 30 | 6 (0)|
| 4 | TABLE ACCESS BY INDEX ROWID| SCORE_RESULT | 1 | 17 | 4 (0)|
| 5 | INDEX RANGE SCAN | SR_FINAL_DECISION_IDX | 1 | | 3 (0)|
| 6 | TABLE ACCESS BY INDEX ROWID| WEB_SCORECARD | 1 | 13 | 2 (0)|
| 7 | INDEX UNIQUE SCAN | WEB_SCORECARD_PK | 1 | | 1 (0)|
| 8 | TABLE ACCESS BY INDEX ROWID | PRODUCT | 1 | 9 | 1 (0)|
| 9 | INDEX UNIQUE SCAN | PK_PRODUCT | 1 | | 0 (0)|
---------------------------------------------------------------------------------------------The output from the 'bad' server:
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
| 0 | SELECT STATEMENT | | 1 | 32 | 8344 (3)|
| 1 | SORT AGGREGATE | | 1 | 32 | |
| 2 | HASH JOIN | | 10887 | 340K| 8344 (3)|
| 3 | TABLE ACCESS FULL | PRODUCT | 6 | 42 | 3 (0)|
| 4 | HASH JOIN | | 34381 | 839K| 8340 (3)|
| 5 | VIEW | index$_join$_001 | 34381 | 503K| 2193 (3)|
| 6 | HASH JOIN | | | | |
| 7 | INDEX RANGE SCAN | SR_FINAL_DECISION_IDX | 34381 | 503K| 280 (3)|
| 8 | INDEX FAST FULL SCAN| SCORE_RESULT_PK | 34381 | 503K| 1371 (2)|
| 9 | TABLE ACCESS FULL | WEB_SCORECARD | 489K| 4782K| 6137 (4)|
----------------------------------------------------------------------------------------I hope the formatting makes this readable.
Stats (from SQL Developer), good table:NUM_ROWS 489716
BLOCKS 27198
AVG_ROW_LEN 312
SAMPLE_SIZE 489716
LAST_ANALYZED 15.12.2009
LAST_ANALYZED_SINCE 15.12.2009Stats (from SQL Developer), bad table:
NUM_ROWS 489716
BLOCKS 27199
AVG_ROW_LEN 395
SAMPLE_SIZE 489716
LAST_ANALYZED 17.12.2009
LAST_ANALYZED_SINCE 17.12.2009I'm unsure what would cause the difference in average row length.
I could obviously try to tune our sql-statements to work on the server not behaving better, but I would rather understand why they are different and make sure that we can expect similar behaviour between environments.
Thank you again for trying to help me.
Håkon
Edited by: ergates on 17.des.2009 05:57
Edited by: ergates on 17.des.2009 06:02
Similar Messages
-
How can I set up two iPhones with the same contact, photos, music etc... but a different sim card and phone number. They will both be my phones, but one will be for use in other countries.
Phone A = phone with information you want duplicated
Phone B = phone that you want to copy from A
Backup Phone A.
Wipe Phone B using these instructions. What to do before selling or giving away your iPhone, iPad, or iPod touch - Apple Support
Phone B should be on the 'Hello' screen. Do not swipe it. Launch iTunes. Plug in Phone B.
When iTunes asks if you want to set up as new phone or restore from backup, choose restore from backup of Phone A.
After this setup, any changes to one phone (i.e. adding a contact, downloading an app) will have to be manually duplicated on the second phone, if that is your desire). Making changes to one phone will not affect the other after setup. -
Same query with different explain plans
Hi All,
I have one of the select query with different explain plans on two separate env, the query fetches the correct index on test env whereas on prod it's not fetching the same index.
The structure, indices, no. of rows are similar in CRMINFO table with up-to-date statistics.
Env Details :
OS - Sun Solaris 5.10
DB - 10.2.0.4
Init param:
Optimizer_mode = ALL_ROWS
optimizer_dynamic_sampling integer 5
optimizer_features_enable string 10.2.0.4
optimizer_index_caching integer 90
optimizer_index_cost_adj integer 30
Query :*
SELECT COUNT (*)
FROM CRMINFO
WHERE RETAILER = :1
AND STATUS = 20
AND EXC = :1
AND SUBNO IS NULL
Expain Plan (TST):
SELECT STATEMENT ALL_ROWSCost: 916 Bytes: 19 Cardinality: 1
3 SORT AGGREGATE Bytes: 19 Cardinality: 1
2 TABLE ACCESS BY INDEX ROWID TABLE TST.CRMINFO Cost: 916 Bytes: 16,663 Cardinality: 877
1 INDEX RANGE SCAN INDEX TST.CRMINFO_X1 Cost: 42 Cardinality: 12,549
Index (TST):
CRMINFO_X1(EXC, RETAILER, STATUS)
Explain Plan (PROD):
SELECT STATEMENT ALL_ROWSCost: 1,832 Bytes: 19 Cardinality: 1
3 SORT AGGREGATE Bytes: 19 Cardinality: 1
2 TABLE ACCESS BY INDEX ROWID TABLE PROD.CRMINFO Cost: 1,832 Bytes: 2,052 Cardinality: 108
1 INDEX RANGE SCAN INDEX PROD.CRMINFO_X2 Cost: 117 Cardinality: 42,519
Index (PROD):
CRMINFO_X2 (RETAILER)
How does Oracle calculates the cost and decides which index it should fetch ? Why it didn't choose the same index as of test env? How should i approach and which domains i need to dig-in to find the cause?
I did try playing with the above mentioned init parameters but it didn't help at all.
Thanks.
Regards,
~PointerPointer wrote:
Hmm, my worry is how do i force oracle to grap the proper index on prod i.e (CRMINFO_X1). I certainly believe it's a bad approach on adding a hint in the select statement and to force oralce to fetch that index.Why do you believe that, the index you mention is the "proper" index versus what Oracle is choosing? Can you prove with hinting that the "proper" index results in a faster and more efficient execution plan? If it does, then the next place I would look at is the statistics for the tables and columns of interest. From here you could try and estimate why Oracle thinks the other index is better. Another option is to run a 10053 (CBO) trace and see why Oracle thinks it is better.
I would not support a hint in a production environment, except in the most extreme cases. Usually the CBO makes the right choice, but it only can if the statistics match the distribution of data.
Refreshing the data may help me simulating the issue on TST but it wouldn't help me to understand why on prod it uses CRMINFO_X2 instead of CRMINFO_X1 which has all the three columns in the Where clause of the query.It would help because it's a test environment and you wouldn't have to do any queries directly on your production system to achieve the same results.
>
A bad thought here :( , if i create a new index by changing the column positioning say like ( RETAILER, STATUS , EXC) instead of (EXC, RETAILER, STATUS) will oracle fetch it ? or would it help in reducing the cost and cardinatlity of the select query.It's not that easy. There is a lot that goes into the cost calculation, some of that is known (through the great work by Jonathan Lewis and Richard Foote), and some of that is purely internal to Oracle. If you are more interested in the internals Cost-Based Oracle Fundamentals by Jonathan Lewis is a great book.
HTH! -
Query returns different Explain Plan
Hi,
I have two databases that are identical to each other. But I have a query that runs on both and returns different explain plans in both. It runs slower in one than other. How can I troubleshoot this further to get faster times in the slower database?
THanks,
PrachiQuery:
=====
SELECT sum(total_contacts), sum(email_partner_news), sum(email_tech_news),
sum(email_enduser_news), sum(email), sum(email_gmo), sum(gmo_nophone),
sum(email_gmo_noaddress), sum(email_gmo_address), sum(
email_gmo_nocertaddr), sum(email_gmo_certaddress), sum(
email_gmo_nophone_noaddr), sum(phone_number), sum(gmo_with_phone),
sum(phone_number_email_gmo_noaddr), sum(phone_number_email_gmo_nocert),
sum(phone_number_address), sum(phone_number_address_noemail), sum(
phone_address_email_nogmo), sum(phone_number_address_email), sum(
phone_number_certaddr), sum(phone_number_certaddr_noemail), sum(
phone_certaddr_email_nogmo), sum(phone_number_address_gmo), sum(
phone_certaddr_email_gmo), sum(address), sum(
address_nophone_number_nogmo), sum(address_certified), sum(
certaddr_nophone_nogmo), sum(address_email_nophone_gmo), sum(
certaddr_email_nophone_gmo), sum(phone_gmo), sum(smail_gmo), sum(fax_gmo
), sum(email_wcast), sum(email_inews), sum(email_salrt), sum(
phone_gmo_phone), sum(smail_gmo_address), sum(fax_gmo_fax)
FROM contact_values_vw_tc_2 cv, ((SELECT gcd_contact_id
FROM contact_values)
INTERSECT
((SELECT gcd_contact_id
FROM gcddata.contact_country s, gcd.country c,
segmentation_query_values v
WHERE s.country_id = c.country_id
AND c.region_id = v.query_value
AND v.selection_type = 'I'
AND v.query_id = 2088
AND v.query_sequence = 1)
INTERSECT
(SELECT gcd_contact_id
FROM gcddata.contact_country s, gcd.country c,
segmentation_query_values v
WHERE s.country_id = c.country_id
AND c.sub_region_id = v.query_value
AND v.selection_type = 'I'
AND v.query_id = 2088
AND v.query_sequence = 2)) ) sl
WHERE cv.gcd_contact_id = sl.gcd_contact_id
AND cv.country_id IN (SELECT cm.country_id
FROM segmentation_user_country_map cm
WHERE cm.user_name = 'E30590')
========================================
Execution Plan - FAST
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=32931 Card=1 Bytes=73)
1 0 SORT (AGGREGATE)
2 1 HASH JOIN (Cost=32931 Card=386388 Bytes=28206324)
3 2 VIEW (Cost=29617 Card=1142043 Bytes=14846559)
4 3 INTERSECTION
5 4 SORT (UNIQUE)
6 5 INDEX (FAST FULL SCAN) OF 'CONTACT_VALUES1_PK' (UNIQUE) (Cost=5 Card=1907737 Bytes=11446422)
7 4 INTERSECTION
8 7 SORT (UNIQUE)
9 8 HASH JOIN (Cost=655 Card=1998575 Bytes=57958675)
10 9 HASH JOIN (Cost=6 Card=110 Bytes=2200)
11 10 TABLE ACCESS (BY INDEX ROWID) OF 'SEGMENTATION_QUERY_VALUES' (Cost=3 Card=7 Bytes=91)
12 11 INDEX (RANGE SCAN) OF 'SEG_QUERY_VALUES_ PK' (UNIQUE) (Cost=2 Card=15)
13 10 TABLE ACCESS (FULL) OF 'COUNTRY' (Cost=2 Card=120 Bytes=840)
14 9 TABLE ACCESS (FULL) OF 'CONTACT_COUNTRY1' (Cost=643 Card=2199855 Bytes=19798695)
15 7 SORT (UNIQUE)
16 15 HASH JOIN (Cost=655 Card=1142043 Bytes=33119247)
17 16 HASH JOIN (Cost=6 Card=63 Bytes=1260)
18 17 TABLE ACCESS (BY INDEX ROWID) OF 'SEGMENTATION_QUERY_VALUES' (Cost=3 Card=7 Bytes=91)
19 18 INDEX (RANGE SCAN) OF 'SEG_QUERY_VALUES_PK' (UNIQUE) (Cost=2 Card=15)
20 17 TABLE ACCESS (FULL) OF 'COUNTRY' (Cost=2 Card=120 Bytes=840)
21 16 TABLE ACCESS (FULL) OF 'CONTACT_COUNTRY1' (Cost=643 Card=2199855 Bytes=19798695)
22 2 HASH JOIN (Cost=2174 Card=645445 Bytes=38726700)
23 22 SORT (UNIQUE)
24 23 TABLE ACCESS (FULL) OF 'SEGMENTATION_USER_COUNTRY_MAP' (Cost=5 Card=43 Bytes=473)
25 22 TABLE ACCESS (FULL) OF 'CONTACT_VALUES1' (Cost=2151 Card=1907737 Bytes=93479113)
=====================================================
Execution Plan -SLOW
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=8751 Card=1 Bytes=73 )
1 0 SORT (AGGREGATE)
2 1 HASH JOIN (SEMI) (Cost=8751 Card=14477 Bytes=1056821)
3 2 MERGE JOIN (Cost=8583 Card=89527 Bytes=5550674)
4 3 TABLE ACCESS (BY INDEX ROWID) OF 'CONTACT_VALUES1' ( Cost=826 Card=1852109 Bytes=90753341)
5 4 INDEX (FULL SCAN) OF 'CONTACT_VALUES1_PK' (UNIQUE) (Cost=26 Card=1852109)
6 3 SORT (JOIN) (Cost=7757 Card=89527 Bytes=1163851)
7 6 VIEW (Cost=7454 Card=89527 Bytes=1163851)
8 7 INTERSECTION
9 8 SORT (UNIQUE)
10 9 INDEX (FAST FULL SCAN) OF 'CONTACT_VALUES1_PK' (UNIQUE) (Cost=5 Card=1852109 Bytes=11112654)
11 8 INTERSECTION
12 11 SORT (UNIQUE)
13 12 HASH JOIN (Cost=640 Card=250676 Bytes=7269604)
14 13 HASH JOIN (Cost=6 Card=28 Bytes=560)
15 14 TABLE ACCESS (BY INDEX ROWID) OF 'SEGMENTATION_QUERY_VALUES' (Cost=3 Card=1 Bytes=13)
16 15 INDEX (RANGE SCAN) OF 'SEG_QUERY_VALUES_PK' (UNIQUE) (Cost=2 Card=2)
17 14 TABLE ACCESS (FULL) OF 'COUNTRY' (Cost =2 Card=120 Bytes=840)
18 13 TABLE ACCESS (FULL) OF 'CONTACT_COUNTRY1 ' (Cost=628 Card=2135370 Bytes=19218330)
19 11 SORT (UNIQUE)
20 19 HASH JOIN (Cost=640 Card=89527 Bytes=25962 83)
21 20 HASH JOIN (Cost=6 Card=10 Bytes=200)
22 21 TABLE ACCESS (BY INDEX ROWID) OF 'SEGMENTATION_QUERY_VALUES' (Cost=3 Card=1 Bytes=13)
23 22 INDEX (RANGE SCAN) OF 'SEG_QUERY_VALUES_PK' (UNIQUE) (Cost=2 Card=2)
24 21 TABLE ACCESS (FULL) OF 'COUNTRY' (Cost =2 Card=120 Bytes=840)
25 20 TABLE ACCESS (FULL) OF 'CONTACT_COUNTRY1 ' (Cost=628 Card=2135370 Bytes=19218330)
26 2 TABLE ACCESS (FULL) OF 'SEGMENTATION_USER_COUNTRY_MAP'
(Cost=5 Card=45 Bytes=495) -
Why two different explain plan for same objects?
Believe or not there are two different databases, one for processing and one for reporting, plan is show different for same query. Table structure and indexes are same. It's 11G
Thanks
Good explain plan .. works fine..
Plan
SELECT STATEMENT ALL_ROWSCost: 12,775 Bytes: 184 Cardinality: 1
27 SORT UNIQUE Cost: 12,775 Bytes: 184 Cardinality: 1
26 NESTED LOOPS
24 NESTED LOOPS Cost: 12,774 Bytes: 184 Cardinality: 1
22 HASH JOIN Cost: 12,772 Bytes: 178 Cardinality: 1
20 NESTED LOOPS SEMI Cost: 30 Bytes: 166 Cardinality: 1
17 NESTED LOOPS Cost: 19 Bytes: 140 Cardinality: 1
14 NESTED LOOPS OUTER Cost: 16 Bytes: 84 Cardinality: 1
11 VIEW DSSADM. Cost: 14 Bytes: 37 Cardinality: 1
10 NESTED LOOPS
8 NESTED LOOPS Cost: 14 Bytes: 103 Cardinality: 1
6 NESTED LOOPS Cost: 13 Bytes: 87 Cardinality: 1
3 INLIST ITERATOR
2 TABLE ACCESS BY INDEX ROWID TABLE DSSODS.DRV_PS_JOB_FAMILY_TBL Cost: 10 Bytes: 51 Cardinality: 1
1 INDEX RANGE SCAN INDEX DSSODS.DRV_PS_JOB_FAMILY_TBL_CL_SETID Cost: 9 Cardinality: 1
5 TABLE ACCESS BY INDEX ROWID TABLE DSSADM.DIM_JOBCODE Cost: 3 Bytes: 36 Cardinality: 1
4 INDEX RANGE SCAN INDEX DSSADM.STAN_JB_FN_IDX Cost: 2 Cardinality: 1
7 INDEX UNIQUE SCAN INDEX (UNIQUE) DSSODS.DRV_PS_JOBCODE_TBL_SEQ_KEY_RPT Cost: 0 Cardinality: 1
9 TABLE ACCESS BY INDEX ROWID TABLE DSSODS.DRV_PS_JOBCODE_TBL_RPT Cost: 1 Bytes: 16 Cardinality: 1
13 TABLE ACCESS BY INDEX ROWID TABLE DSSODS.DRV_PSXLATITEM_RPT Cost: 2 Bytes: 47 Cardinality: 1
12 INDEX RANGE SCAN INDEX DSSODS.PK_DRV_RIXLATITEM_RPT Cost: 1 Cardinality: 1
16 TABLE ACCESS BY INDEX ROWID TABLE DSSADM.DIM_JOBCODE Cost: 3 Bytes: 56 Cardinality: 1
15 INDEX RANGE SCAN INDEX DSSADM.DIM_JOBCODE_EXPDT1 Cost: 2 Cardinality: 1
19 TABLE ACCESS BY INDEX ROWID TABLE DSSODS.DRV_PS_JOB_RPT Cost: 11 Bytes: 438,906 Cardinality: 16,881
18 INDEX RANGE SCAN INDEX DSSODS.DRV_PS_JOB_JOBCODE_RPT Cost: 2 Cardinality: 8
21 INDEX FAST FULL SCAN INDEX (UNIQUE) DSSADM.Z_PK_JOBCODE_PROMPT_TBL Cost: 12,699 Bytes: 66,790,236 Cardinality: 5,565,853
23 INDEX RANGE SCAN INDEX DSSADM.DIM_PERSON_EMPL_RCD_SEQ_KEY Cost: 1 Cardinality: 1
25 TABLE ACCESS BY INDEX ROWID TABLE DSSADM.DIM_PERSON_EMPL_RCD Cost: 2 Bytes: 6 Cardinality: 1 This bad plan ... show merge join cartesian and full table ..
Plan
SELECT STATEMENT ALL_ROWSCost: 3,585 Bytes: 237 Cardinality: 1
26 SORT UNIQUE Cost: 3,585 Bytes: 237 Cardinality: 1
25 NESTED LOOPS SEMI Cost: 3,584 Bytes: 237 Cardinality: 1
22 NESTED LOOPS Cost: 3,573 Bytes: 211 Cardinality: 1
20 MERGE JOIN CARTESIAN Cost: 2,864 Bytes: 70,446 Cardinality: 354
17 NESTED LOOPS
15 NESTED LOOPS Cost: 51 Bytes: 191 Cardinality: 1
13 NESTED LOOPS OUTER Cost: 50 Bytes: 180 Cardinality: 1
10 HASH JOIN Cost: 48 Bytes: 133 Cardinality: 1
6 NESTED LOOPS
4 NESTED LOOPS Cost: 38 Bytes: 656 Cardinality: 8
2 TABLE ACCESS BY INDEX ROWID TABLE REPORT2.DIM_JOBCODE Cost: 14 Bytes: 448 Cardinality: 8
1 INDEX RANGE SCAN INDEX REPORT2.STAN_PROM_JB_IDX Cost: 6 Cardinality: 95
3 INDEX RANGE SCAN INDEX REPORT2.SETID_JC_IDX Cost: 2 Cardinality: 1
5 TABLE ACCESS BY INDEX ROWID TABLE REPORT2.DIM_JOBCODE Cost: 3 Bytes: 26 Cardinality: 1
9 INLIST ITERATOR
8 TABLE ACCESS BY INDEX ROWID TABLE REPORT2.DRV_PS_JOB_FAMILY_TBL Cost: 10 Bytes: 51 Cardinality: 1
7 INDEX RANGE SCAN INDEX REPORT2.DRV_PS_JOB_FAMILY_TBL_CL_SETID Cost: 9 Cardinality: 1
12 TABLE ACCESS BY INDEX ROWID TABLE REPORT2.DRV_PSXLATITEM_RPT Cost: 2 Bytes: 47 Cardinality: 1
11 INDEX RANGE SCAN INDEX REPORT2.PK_DRV_RIXLATITEM_RPT Cost: 1 Cardinality: 1
14 INDEX UNIQUE SCAN INDEX (UNIQUE) REPORT2.DRV_PS_JOBCODE_TBL_SEQ_KEY_RPT Cost: 0 Cardinality: 1
16 TABLE ACCESS BY INDEX ROWID TABLE REPORT2.DRV_PS_JOBCODE_TBL_RPT Cost: 1 Bytes: 11 Cardinality: 1
19 BUFFER SORT Cost: 2,863 Bytes: 4,295,552 Cardinality: 536,944
18 TABLE ACCESS FULL TABLE REPORT2.DIM_PERSON_EMPL_RCD Cost: 2,813 Bytes: 4,295,552 Cardinality: 536,944
21 INDEX RANGE SCAN INDEX (UNIQUE) REPORT2.Z_PK_JOBCODE_PROMPT_TBL Cost: 2 Bytes: 12 Cardinality: 1
24 TABLE ACCESS BY INDEX ROWID TABLE REPORT2.DRV_PS_JOB_RPT Cost: 11 Bytes: 1,349,920 Cardinality: 51,920
23 INDEX RANGE SCAN INDEX REPORT2.DRV_PS_JOB_JOBCODE_RPT Cost: 2 Cardinality: 8user550024 wrote:
I am really surprise that the stat for good sql are little old. I just computed the states of bad sql so they are uptodate..
There is something terribly wrong..Not necessarily. Just using the default stats collection I've seen a few cases of things suddenly going wrong. As the data increases, it gets closer to an edge case where the inadequacy of the statistics convinces the optimizer to do a wrong plan. To fix, I could just go into dbconsole, set the stats back to a time when they worked, and locked them. In most cases it's definitely better to figure out what is really going on, though, to give the optimizer better information to work with. Aside from the value of learning how to do it, for some cases it's not so simple. Also, many think the default settings of the database statistic collection may be wrong in general (in 10.2.x, at least). So much depends on your application and data that you can't make too many generalizations. You have to look at the evidence and figure it out. There is still a steep learning curve for the tools to look at the evidence. People are here to help with that.
Most of the time it works better than a dumb rule based optimizer, but at the cost of a few situations where people are smarter than computers. It's taken a lot of years to get to this point. -
Same Query...Same DB Instance....Different results
Hi,
I'm running into an issue in which I'm seeing inconsistent results. If I run a query against a static table (fully committed) sometimes I receive one result set and at other times I receive another result set.This does not seem to be limited to a particular table or query. The database has been setup for a data warehouse for a client using the following init params....
cursor_space_for_time=true
db_block_size=16K
db_file_multiblock_read_count=32
db_writer_processes=[number of CPUs]
filesystemio_options=asych
statistics_level=ALL
star_transformation_enable=true
We have implemented this database/setup at least a dozen times with no issues. Does anyone have any suggestions on how to approach identifying the source of this problem? We are unable to duplicate it outside of this environment....making it difficult for us to open a TAR. The client is using Oracle 10g with all of the latest service packs.
Any assistance would be greatly appreciated.
Thanks!Hi,
I'm running into an issue in which I'm seeing
inconsistent results. If I run a query against a
static table (fully committed) sometimes I receive
one result set and at other times I receive another
result set.This does not seem to be limited to a
particular table or query. The database has been
setup for a data warehouse for a client using the
following init params....
There have been bugs in 10g which have this effect - and I came across one quite recently. I wasn't aware of any that were still around in 10.2.0.4, though. Raise an SR with Oracle.
cursor_space_for_time=true
db_file_multiblock_read_count=32
db_writer_processes=[number of CPUs]
statistics_level=ALLProbably not relevant to your problem but these are all slightly suspect settings. You don't usually need to lock cursor frames in a data waarehouse - getting the right execution plan is usually more important than sharing existing cursors.
10gR2 the ideal is to reset db_file_multiblock_read_count and let the Oracle maximise the efficiency of multiblock reads by itself.
db_writers > 1 is rarely needed, and setting it to match the CPU_COUNT can be positively counter-productive (see http://kevinclosson.wordpress.com for further commentary).
Statistics_level = all enables rowsource execution statistics and can, depending on the cost of calling the system timer, be extremely CPU intensive. (See http://jonathanlewis.wordpress.com/2007/04/26/heisenberg/ for an example).
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk
"The greatest enemy of knowledge is not ignorance,
it is the illusion of knowledge." (Stephen Hawking) -
Why same query runs on isqlplus but not in Forms/Reports trigger
Hi,
I have one query in which I extract one column with parent table join if I run same query on isqlplus prompt it works but if I run same on Forms/Reports trigger it says found "select" where something else expected.
below is an example .
select em1.mreading, em1.grid_code,
(select em.mreading from energy_mreading em where em.grid_code=em1.grid_code and em.transformer_code=em1.transformer_code
and em.bus_bar=em1.bus_bar and to_date(to_char(em.r_date,'dd/mm/yyyy'),'dd/mm/yy') = to_date('02/01/07' ,'dd/mm/yy') - 1)
as Yreading
from energy_mreading em1
where to_date(to_char(em1.r_date,'dd/mm/yyyy'),'dd/mm/yy')= to_date('02/01/07' ,'dd/mm/yy')
Any one can help me, is there any restriction/limitations in Forms/Reports triggers.
Thanks, Khawar.In forms and cursors you can not use scalar subqueries as you do. You have to use joins!
select
em1.mreading
,em1.grid_code
,em.mreading as Yreading
from
energy_mreading em1
,energy_mreading em
where 1=1
and trunc(em1.r_date) = to_date('02/01/2007','dd/mm/rrrr')
and em.grid_code = em1.grid_code
and em.transformer_code = em1.transformer_code
and em.bus_bar = em1.bus_bar
and trunc(em.r_date) = trunc(em1.r_date) - 1
Try this, hope it works. -
Same query runs with a lot of difference of speed on two machines
Dear All,
I am facing a strange problem.
A query which when run in SQL*Plus/Toad/Oracle SQL Developer, gives output within fraction of seconds. But when i run the same query in my home it takes about hour to produce output.
Using schema script i managed to have the same database setup at my home. My home PC is having better processor than company PC and having same memory.
In company the database server is linux and i access it using a Oracle client, but in home it is on same PC.
I am sure that i am running the same query with the same database as i had run another queries successfully on the same database.
Then how do this come?
Am i missing something? Any idea?
Do revert.
Thanks in advance.
-SameerIts possible that network communcations is part of what you're seeing. TOAD can wait until it gets back all the data you are querying; a lot of data could take awhile to transfer off-site. If not network it could be something else in your environment.
Try writing a PL/SQL cursor to be executed inside the database without bringing data back to the client and time it to see if merely selecting the data on the server takes a long time. -
Explain plans differ: same query, cloned databases.
oracle 10.2.0.2.0
solaris 10
same query, different databases (cloned from same source), different explain plans.
db parameters are identical.
Any ideas?
DB1 (production)
SQL> explain plan for
2 SELECT V__101.*, SHAPE.fid,SHAPE.numofpts,SHAPE.entity,SHAPE.points,
3 SHAPE.rowid
4 FROM
5 (SELECT b.OBJECTID,b.CRT_DTE,b.CRT_SRC_CDE,b.CRT_AQUI_MTHD_CDE,b.CRT_USR_ID,
6 b.ADT_ACTN_CDE,b.ADT_ACTN_DTE,b.ADT_ACTN_SRC_CDE,b.ADT_ACTN_USR_ID,
7 b.TP_SITE_POINT_ID,b.SHAPE,b.SRC_ID,b.SRC_CRT_DTE,b.SRC_TYPE_CDE,
8 b.LCTN_STAT_CDE,b.FRZN_LCTN_IND,b.TP_NOTES FROM AMSOWNER.TP_SITE_POINT b
9 WHERE b.OBJECTID NOT IN (SELECT /*+ HASH_AJ */ SDE_DELETES_ROW_ID FROM
10 AMSOWNER.D101 WHERE DELETED_AT IN (SELECT l.lineage_id FROM
SDE.state_lineages l WHERE l.lineage_name = :source_lineage_name AND
11 12 l.lineage_id <= :source_state_id) AND SDE_STATE_ID = :"SYS_B_0") UNION ALL
SELECT a.OBJECTID,a.CRT_DTE,a.CRT_SRC_CDE,a.CRT_AQUI_MTHD_CDE,a.CRT_USR_ID,
13 14 a.ADT_ACTN_CDE,a.ADT_ACTN_DTE,a.ADT_ACTN_SRC_CDE,a.ADT_ACTN_USR_ID,
15 a.TP_SITE_POINT_ID,a.SHAPE,a.SRC_ID,a.SRC_CRT_DTE,a.SRC_TYPE_CDE,
16 a.LCTN_STAT_CDE,a.FRZN_LCTN_IND,a.TP_NOTES FROM AMSOWNER.A101 a,
17 SDE.state_lineages SL WHERE (a.OBJECTID, a.SDE_STATE_ID) NOT IN (SELECT /*+
18 HASH_AJ */ SDE_DELETES_ROW_ID,SDE_STATE_ID FROM AMSOWNER.D101 WHERE
19 DELETED_AT IN (SELECT l.lineage_id FROM SDE.state_lineages l WHERE
20 l.lineage_name = :source_lineage_name AND l.lineage_id <= :source_state_id)
21 AND SDE_STATE_ID > :"SYS_B_1") AND a.SDE_STATE_ID = SL.lineage_id AND
22 SL.lineage_name = :source_lineage_name AND SL.lineage_id <=
23 :source_state_id ) V__101 , AMSOWNER.F15 SHAPE where SHAPE.FID(+) =
24 V__101.SHAPE;
Explained.
SQL> @?/rdbms/admin/utlxplp.sql;
PLAN_TABLE_OUTPUT
Plan hash value: 254376361
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 113K| 49M| | 2926 (1)| 00:00:41 |
|* 1 | HASH JOIN RIGHT OUTER | | 113K| 49M| 17M| 2926 (1)| 00:00:41 |
| 2 | TABLE ACCESS FULL | F15 | 113K| 15M| | 344 (2)| 00:00:05 |
| 3 | VIEW | | 113K| 34M| | 331 (2)| 00:00:05 |
| 4 | UNION-ALL | | | | | | |
|* 5 | HASH JOIN RIGHT ANTI | | 113K| 8948K| | 332 (2)| 00:00:05 |
| 6 | VIEW | VW_NSO_1 | 1 | 13 | | 2 (0)| 00:00:01 |
| 7 | NESTED LOOPS | | 1 | 50 | | 2 (0)| 00:00:01 |
| 8 | TABLE ACCESS BY INDEX ROWID| D101 | 1 | 39 | | 1 (0)| 00:00:01 |
|* 9 | INDEX SKIP SCAN | D101_IDX1 | 1 | | | 1 (0)| 00:00:01 |
|* 10 | INDEX UNIQUE SCAN | LINEAGES_PK | 1 | 11 | | 1 (0)| 00:00:01 |
| 11 | TABLE ACCESS FULL | TP_SITE_POINT | 113K| 7512K| | 329 (2)| 00:00:05 |
|* 12 | HASH JOIN ANTI | | 1 | 375 | | 5 (20)| 00:00:01 |
| 13 | NESTED LOOPS | | 1 | 349 | | 2 (0)| 00:00:01 |
| 14 | TABLE ACCESS BY INDEX ROWID | A101 | 1 | 338 | | 1 (0)| 00:00:01 |
|* 15 | INDEX RANGE SCAN | A101_STATEID_IX1 | 1 | | | 1 (0)| 00:00:01 |
|* 16 | INDEX UNIQUE SCAN | LINEAGES_PK | 1 | 11 | | 1 (0)| 00:00:01 |
|* 17 | VIEW | VW_NSO_2 | 1 | 26 | | 2 (0)| 00:00:01 |
| 18 | NESTED LOOPS | | 1 | 50 | | 2 (0)| 00:00:01 |
|* 19 | INDEX FULL SCAN | D101_PK | 1 | 39 | | 1 (0)| 00:00:01 |
|* 20 | INDEX UNIQUE SCAN | LINEAGES_PK | 1 | 11 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - access("SHAPE"."FID"(+)="V__101"."SHAPE")
5 - access("B"."OBJECTID"="$nso_col_1")
9 - access("SDE_STATE_ID"=TO_NUMBER(:SYS_B_0))
filter("SDE_STATE_ID"=TO_NUMBER(:SYS_B_0))
10 - access("L"."LINEAGE_NAME"=TO_NUMBER(:SOURCE_LINEAGE_NAME) AND "DELETED_AT"="L"."LINEAGE_ID")
filter("L"."LINEAGE_ID"<=TO_NUMBER(:SOURCE_STATE_ID))
12 - access("A"."OBJECTID"="$nso_col_1" AND "A"."SDE_STATE_ID"="$nso_col_2")
15 - access("A"."SDE_STATE_ID"<=TO_NUMBER(:SOURCE_STATE_ID))
16 - access("SL"."LINEAGE_NAME"=TO_NUMBER(:SOURCE_LINEAGE_NAME) AND
"A"."SDE_STATE_ID"="SL"."LINEAGE_ID")
filter("SL"."LINEAGE_ID"<=TO_NUMBER(:SOURCE_STATE_ID))
17 - filter("$nso_col_2"<=TO_NUMBER(:SOURCE_STATE_ID))
19 - access("SDE_STATE_ID">TO_NUMBER(:SYS_B_1))
filter("SDE_STATE_ID">TO_NUMBER(:SYS_B_1))
20 - access("L"."LINEAGE_NAME"=TO_NUMBER(:SOURCE_LINEAGE_NAME) AND "DELETED_AT"="L"."LINEAGE_ID")
filter("L"."LINEAGE_ID"<=TO_NUMBER(:SOURCE_STATE_ID))
47 rows selected.DB2 (staging)
SQL> explain plan for
2 SELECT V__101.*, SHAPE.fid,SHAPE.numofpts,SHAPE.entity,SHAPE.points,
SHAPE.rowid
FROM
3 4 5 (SELECT b.OBJECTID,b.CRT_DTE,b.CRT_SRC_CDE,b.CRT_AQUI_MTHD_CDE,b.CRT_USR_ID,
b.ADT_ACTN_CDE,b.ADT_ACTN_DTE,b.ADT_ACTN_SRC_CDE,b.ADT_ACTN_USR_ID,
6 7 b.TP_SITE_POINT_ID,b.SHAPE,b.SRC_ID,b.SRC_CRT_DTE,b.SRC_TYPE_CDE,
8 b.LCTN_STAT_CDE,b.FRZN_LCTN_IND,b.TP_NOTES FROM AMSOWNER.TP_SITE_POINT b
9 WHERE b.OBJECTID NOT IN (SELECT /*+ HASH_AJ */ SDE_DELETES_ROW_ID FROM
10 AMSOWNER.D101 WHERE DELETED_AT IN (SELECT l.lineage_id FROM
11 SDE.state_lineages l WHERE l.lineage_name = :source_lineage_name AND
12 l.lineage_id <= :source_state_id) AND SDE_STATE_ID = :"SYS_B_0") UNION ALL
13 SELECT a.OBJECTID,a.CRT_DTE,a.CRT_SRC_CDE,a.CRT_AQUI_MTHD_CDE,a.CRT_USR_ID,
14 a.ADT_ACTN_CDE,a.ADT_ACTN_DTE,a.ADT_ACTN_SRC_CDE,a.ADT_ACTN_USR_ID,
15 a.TP_SITE_POINT_ID,a.SHAPE,a.SRC_ID,a.SRC_CRT_DTE,a.SRC_TYPE_CDE,
16 a.LCTN_STAT_CDE,a.FRZN_LCTN_IND,a.TP_NOTES FROM AMSOWNER.A101 a,
17 SDE.state_lineages SL WHERE (a.OBJECTID, a.SDE_STATE_ID) NOT IN (SELECT /*+
HASH_AJ */ SDE_DELETES_ROW_ID,SDE_STATE_ID FROM AMSOWNER.D101 WHERE
18 19 DELETED_AT IN (SELECT l.lineage_id FROM SDE.state_lineages l WHERE
20 l.lineage_name = :source_lineage_name AND l.lineage_id <= :source_state_id)
21 AND SDE_STATE_ID > :"SYS_B_1") AND a.SDE_STATE_ID = SL.lineage_id AND
22 SL.lineage_name = :source_lineage_name AND SL.lineage_id <=
23 :source_state_id ) V__101 , AMSOWNER.F15 SHAPE where SHAPE.FID(+) =
24 V__101.SHAPE;
Explained.
SQL> @?/rdbms/admin/utlxplp.sql;
PLAN_TABLE_OUTPUT
Plan hash value: 4287458713
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 145 | 68150 | 401 (1)| 00:00:06 |
| 1 | NESTED LOOPS OUTER | | 145 | 68150 | 401 (1)| 00:00:06 |
| 2 | VIEW | | 145 | 47125 | 328 (1)| 00:00:05 |
| 3 | UNION-ALL | | | | | |
|* 4 | HASH JOIN ANTI | | 144 | 10224 | 324 (1)| 00:00:05 |
| 5 | TABLE ACCESS FULL | TP_SITE_POINT | 145 | 8410 | 322 (1)| 00:00:05 |
| 6 | VIEW | VW_NSO_1 | 1 | 13 | 2 (0)| 00:00:01 |
| 7 | NESTED LOOPS | | 1 | 50 | 2 (0)| 00:00:01 |
|* 8 | TABLE ACCESS BY INDEX ROWID| D101 | 1 | 39 | 1 (0)| 00:00:01 |
|* 9 | INDEX SKIP SCAN | D101_IDX1 | 1 | | 1 (0)| 00:00:01 |
|* 10 | INDEX UNIQUE SCAN | LINEAGES_PK | 1 | 11 | 1 (0)| 00:00:01 |
|* 11 | FILTER | | | | | |
| 12 | NESTED LOOPS | | 1 | 349 | 2 (0)| 00:00:01 |
| 13 | TABLE ACCESS BY INDEX ROWID | A101 | 1 | 338 | 1 (0)| 00:00:01 |
|* 14 | INDEX RANGE SCAN | A101_STATEID_IX1 | 1 | | 1 (0)| 00:00:01 |
|* 15 | INDEX UNIQUE SCAN | LINEAGES_PK | 1 | 11 | 1 (0)| 00:00:01 |
|* 16 | FILTER | | | | | |
| 17 | NESTED LOOPS | | 1 | 50 | 2 (0)| 00:00:01 |
|* 18 | TABLE ACCESS BY INDEX ROWID| D101 | 1 | 39 | 1 (0)| 00:00:01 |
|* 19 | INDEX RANGE SCAN | D101_IDX1 | 1 | | 1 (0)| 00:00:01 |
|* 20 | INDEX UNIQUE SCAN | LINEAGES_PK | 1 | 11 | 1 (0)| 00:00:01 |
| 21 | TABLE ACCESS BY INDEX ROWID | F15 | 1 | 145 | 1 (0)| 00:00:01 |
|* 22 | INDEX UNIQUE SCAN | F15_UK1 | 1 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
4 - access("B"."OBJECTID"="$nso_col_1")
8 - filter("DELETED_AT"<=TO_NUMBER(:SOURCE_STATE_ID))
9 - access("SDE_STATE_ID"=TO_NUMBER(:SYS_B_0))
filter("SDE_STATE_ID"=TO_NUMBER(:SYS_B_0))
10 - access("L"."LINEAGE_NAME"=TO_NUMBER(:SOURCE_LINEAGE_NAME) AND
"DELETED_AT"="L"."LINEAGE_ID")
filter("L"."LINEAGE_ID"<=TO_NUMBER(:SOURCE_STATE_ID))
11 - filter( NOT EXISTS (SELECT /*+ HASH_AJ */ 0 FROM "AMSOWNER"."D101"
"D101","SDE"."STATE_LINEAGES" "L" WHERE :B1>TO_NUMBER(:SYS_B_1) AND
"DELETED_AT"="L"."LINEAGE_ID" AND "L"."LINEAGE_NAME"=TO_NUMBER(:SOURCE_LINEAGE_NAME) AND
"L"."LINEAGE_ID"<=TO_NUMBER(:SOURCE_STATE_ID) AND "SDE_STATE_ID"=:B2 AND
"SDE_DELETES_ROW_ID"=:B3 AND "DELETED_AT"<=TO_NUMBER(:SOURCE_STATE_ID) AND
"SDE_STATE_ID">TO_NUMBER(:SYS_B_1)))
14 - access("A"."SDE_STATE_ID"<=TO_NUMBER(:SOURCE_STATE_ID))
15 - access("SL"."LINEAGE_NAME"=TO_NUMBER(:SOURCE_LINEAGE_NAME) AND
"A"."SDE_STATE_ID"="SL"."LINEAGE_ID")
filter("SL"."LINEAGE_ID"<=TO_NUMBER(:SOURCE_STATE_ID))
16 - filter(:B1>TO_NUMBER(:SYS_B_1))
18 - filter("DELETED_AT"<=TO_NUMBER(:SOURCE_STATE_ID))
19 - access("SDE_DELETES_ROW_ID"=:B1 AND "SDE_STATE_ID"=:B2)
filter("SDE_STATE_ID">TO_NUMBER(:SYS_B_1))
20 - access("L"."LINEAGE_NAME"=TO_NUMBER(:SOURCE_LINEAGE_NAME) AND
"DELETED_AT"="L"."LINEAGE_ID")
filter("L"."LINEAGE_ID"<=TO_NUMBER(:SOURCE_STATE_ID))
22 - access("SHAPE"."FID"(+)="V__101"."SHAPE")
58 rows selected.rocr wrote:
oracle 10.2.0.2.0
solaris 10
same query, different databases (cloned from same source), different explain plans.
db parameters are identical.
DB1 (production)
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 113K| 49M| | 2926 (1)| 00:00:41 |DB2 (staging)
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 145 | 68150 | 401 (1)| 00:00:06 |
If you check the execution plans it's quite obvious that the two environments can not be identical. If you have the same (amount of) data, then one of the two estimates is way off. Which one is in the right ballpark, how many rows are returned by the query? The same applies to the remaining operation ids of the plan, which estimate is correct?
It's very likely that the underlying table/index statistics are not the same, and therefore you get different plans.
By the way, you're using bind variables, therefore the output of the EXPLAIN PLAN is only of limited use, since the actual plan at run time might be completely different due to bind variable peeking and potentially histograms created on some of the columns (which is the default in 10g due to the "FOR ALL COLUMNS SIZE AUTO" method_opt default parameter value).
If you haven't disabled the pre-configured statistics collection job that runs every night in 10g, you might get different statistics due to this job already.
Regards,
Randolf
Oracle related stuff blog:
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/ -
Query on a table runs more than 45mins(after stats) and same query runs 19secs(before stats - rebuild) - Not sure what the cause is.
- Analysed the explain the plan
- different explain plan used afterr stats gather.
Any idea what could be the cause with this kind of difference.
Thank you!What is the difference you see in the explain plan ? Where it spends most time. All these needs to be analysed.
-
Explain plan changing for the same sql
Hi All,
In a E Business suite application, we have the 10.2.0.4 Database.
One of the program is running a select stmt which is using different explain plan one in a month which is causing issue in the program running for longer time.
Ex : When it uses the index A, it is running fine. When it uses the index B, it is running for longer time.
Can you please advice on the possible reasons for the same sql to choose index B instead of index A some times.
Thanks,
RakeshIt could be that the SQL is question got aged out of the shared pool and when it came to be reparsed - the values in the bind variables were such that access via index b was more attractive than access via index a.
Could you please send the query and the good and bad plans and all other information that might help diagnose the problem..
Note: we had a similiar case where plans suddenly changed for no apperant reason (on 10.2.0.2) - we found that under certain circumstances the optimizer would not peek into the bind varaibles to derive the execution path. -
How can i stop user to get the same screen while entering same T code
hi experts,
how can i stop user to get the same screen while entering same T code (_Means i want user enter same t code but got different different screen how it is possible.)_
i want to know how can we set a authorization is such a manner ...
Through different different login id user got different different screen while entering same T-code.
for example if there is two functional login id mum & noida...
then user login through that and
enter any same functional tcode (for getting purchase order)
but get different different window...so how come it is possible.....
plz explain in brief
thanks in advance...plz do reply as soon as possibleFor a custom transaction this is easy, you need to ask your developers to be able to direct users to different screens based on the results of an authorisation check. You could have an auth field e.g. ZSCREEN which is checked in the program & decides what screen the user has access to.
For standard transactions, unless already coded, I would forget it & do what is recommended by Subramaniam and create transaction variants as required. Assign each variant to a custom t-code and users access it that way.
What I am interested is is why do you want to do this? -
Query Fast In SQLPlus and Toad but Slow Otherwise
Environment is Oracle 10g on AIX with 10g drivers on Windows XP as the client. Several queries run in less than 9 seconds in Toad and SQLPlus but take hours or never return in Business Objects Deski, MS Access, and SQL Server SSIS. The exact same SQL produces completely different explain plans based on if it is run from Toad/SQLPlus vs the other products I mentioned. All the software is on the same XP machine and does not use middleware. 99 percent of our queries will run fast or slow in all products. What is it that Toad and/or SQLPlus does to run the queries fast? Why does Oracle change explain plans based on what application connects to it? The goal is to run Business Objects reports from Oracle. Any help or direction for further troubleshooting would be appreciated. Thank-you.
Charles, on the XP machine I selected the Admin option when installing the client. The software should be 10g R2. Below is the information requested. If you need more please let me know. Also, I am asking our DBA to check the bitmap issue.
I appreciate the help. Thank-you for taking your time...
BAD Settings
SQL_ID CN NAME VALUE DEF
64yzv2570s56x 0 _pga_max_size 209700 KB NO
64yzv2570s56x 0 active_instance_count 1 YES
64yzv2570s56x 0 bitmap_merge_area_size 1048576 YES
64yzv2570s56x 0 cpu_count 4 YES
64yzv2570s56x 0 cursor_sharing similar NO
64yzv2570s56x 0 hash_area_size 131072 YES
64yzv2570s56x 0 optimizer_dynamic_samplin 2 YES
64yzv2570s56x 0 optimizer_features_enable 10.2.0.4 YES
64yzv2570s56x 0 optimizer_index_caching 0 YES
64yzv2570s56x 0 optimizer_index_cost_adj 100 YES
64yzv2570s56x 0 optimizer_mode choose NO
64yzv2570s56x 0 optimizer_secure_view_mer true YES
64yzv2570s56x 0 parallel_ddl_mode enabled YES
64yzv2570s56x 0 parallel_dml_mode disabled YES
64yzv2570s56x 0 parallel_execution_enable true YES
64yzv2570s56x 0 parallel_query_mode enabled YES
64yzv2570s56x 0 parallel_threads_per_cpu 2 YES
64yzv2570s56x 0 pga_aggregate_target 1048576 KB YES
64yzv2570s56x 0 query_rewrite_enabled true YES
64yzv2570s56x 0 query_rewrite_integrity trusted NO
64yzv2570s56x 0 skip_unusable_indexes true YES
64yzv2570s56x 0 sort_area_retained_size 0 YES
64yzv2570s56x 0 sort_area_size 65536 YES
64yzv2570s56x 0 star_transformation_enabl temp_disable NO
64yzv2570s56x 0 statistics_level typical YES
64yzv2570s56x 0 workarea_size_policy auto YES
GOOD Settings
SQL_ID CN NAME VALUE DEF
7y2m07bk7qwgx 0 _pga_max_size 209700 KB NO
7y2m07bk7qwgx 0 active_instance_count 1 YES
7y2m07bk7qwgx 0 bitmap_merge_area_size 1048576 YES
7y2m07bk7qwgx 0 cpu_count 4 YES
7y2m07bk7qwgx 0 cursor_sharing similar NO
7y2m07bk7qwgx 0 hash_area_size 131072 YES
7y2m07bk7qwgx 0 optimizer_dynamic_samplin 2 YES
7y2m07bk7qwgx 0 optimizer_features_enable 10.2.0.4 YES
7y2m07bk7qwgx 0 optimizer_index_caching 0 YES
7y2m07bk7qwgx 0 optimizer_index_cost_adj 100 YES
7y2m07bk7qwgx 0 optimizer_mode choose NO
7y2m07bk7qwgx 0 optimizer_secure_view_mer true YES
7y2m07bk7qwgx 0 parallel_ddl_mode enabled YES
7y2m07bk7qwgx 0 parallel_dml_mode disabled YES
7y2m07bk7qwgx 0 parallel_execution_enable true YES
7y2m07bk7qwgx 0 parallel_query_mode enabled YES
7y2m07bk7qwgx 0 parallel_threads_per_cpu 2 YES
7y2m07bk7qwgx 0 pga_aggregate_target 1048576 KB YES
7y2m07bk7qwgx 0 query_rewrite_enabled true YES
7y2m07bk7qwgx 0 query_rewrite_integrity trusted NO
7y2m07bk7qwgx 0 skip_unusable_indexes true YES
7y2m07bk7qwgx 0 sort_area_retained_size 0 YES
7y2m07bk7qwgx 0 sort_area_size 65536 YES
7y2m07bk7qwgx 0 star_transformation_enabl temp_disable NO
7y2m07bk7qwgx 0 statistics_level typical YES
7y2m07bk7qwgx 0 workarea_size_policy auto YES
BAD Plan
PLAN_TABLE_OUTPUT
SQL_ID 64yzv2570s56x, child number 0
SELECT --q2 DM_FAC.FAC_NM, COUNT(DISTINCT DM_ACCT.ACCT_SK), DM_DRG_SVC_LN.DRG_SVC_LN_DESC
FROM DM_FAC, DM_ACCT, DM_DRG_SVC_LN, DM_ORG_UNIT_GRP, DM_ORG_UNIT_DIV,
DM_DT_QRY DM_DT__DSCH, DM_BILL_LOC, DM_DT_QRY DM_DT_VISITSVC,
FACT_VISIT, DM_RSP_PTY WHERE (
DM_ORG_UNIT_GRP.ORG_UNIT_GRP_SK=DM_ORG_UNIT_DIV.ORG_UNIT_GRP_SK ) AND ( DM_ORG_UNIT_GRP.ARCHIVE_IND
= :"SYS_B_00" ) AND ( DM_DT_VISITSVC.DT2_SK=FACT_VISIT.SVC_DT2_SK ) AND (
DM_BILL_LOC.BILL_LOC_SK=FACT_VISIT.BILL_LOC_SK ) AND (
DM_ORG_UNIT_DIV.ORG_UNIT_DIV_SK=FACT_VISIT.ORG_UNIT_DIV_SK ) AND (
FACT_VISIT.DEL_IND=:"SYS_B_01" ) AND ( DM_RSP_PTY.ACCT_SK=DM_ACCT.ACCT_SK )
AND ( DM_RSP_PTY.RSP_PTY_TYPE_CD=:"SYS_B_02" ) AND ( DM_ACCT.FAC_CD=DM_FAC.FAC_CD ) AND (
DM_ACCT.DSCH_DT=DM_DT__DSCH.DT ) AND ( DM_ACCT.DRG_SVC_LN_SK=DM_DRG_SVC_LN.DRG_SVC_LN
Plan hash value: 2053235935
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | | | 7559 (100)| |
| 1 | SORT GROUP BY | | 1 | 174 | 7559 (2)| 00:00:20 |
|* 2 | FILTER | | | | | |
| 3 | NESTED LOOPS | | 1 | 174 | 7558 (2)| 00:00:20 |
| 4 | NESTED LOOPS | | 1 | 149 | 7557 (2)| 00:00:20 |
|* 5 | HASH JOIN | | 1 | 128 | 7556 (2)| 00:00:20 |
| 6 | NESTED LOOPS | | 6 | 678 | 7543 (2)| 00:00:20 |
| 7 | NESTED LOOPS | | 170 | 15300 | 7201 (2)| 00:00:19 |
|* 8 | HASH JOIN | | 41 | 3239 | 5141 (2)| 00:00:14 |
|* 9 | HASH JOIN | | 75 | 4725 | 5137 (2)| 00:00:14 |
|* 10 | TABLE ACCESS FULL | DM_ORG_UNIT_DIV | 170 | 2550 | 5 (0)| 00:00:01 |
|* 11 | HASH JOIN | | 204 | 9792 | 5131 (2)| 00:00:14 |
|* 12 | TABLE ACCESS FULL | DM_DT_QRY | 7 | 98 | 13 (16)| 00:00:01 |
|* 13 | TABLE ACCESS BY INDEX ROWID| FACT_VISIT | 17647 | 448K| 3893 (2)| 00:00:11 |
| 14 | NESTED LOOPS | | 35294 | 1171K| 5116 (2)| 00:00:14 |
|* 15 | TABLE ACCESS FULL | DM_BILL_LOC | 2 | 16 | 3 (0)| 00:00:01 |
|* 16 | INDEX RANGE SCAN | FV_DMBILLLOC_FK | 35294 | | 105 (4)| 00:00:01 |
|* 17 | TABLE ACCESS FULL | DM_ORG_UNIT_GRP | 57 | 912 | 3 (0)| 00:00:01 |
|* 18 | TABLE ACCESS BY INDEX ROWID | DM_RSP_PTY | 4 | 44 | 50 (0)| 00:00:01 |
|* 19 | INDEX RANGE SCAN | XSI_DMRSPPY_CNRPERSID | 48 | | 2 (0)| 00:00:01 |
|* 20 | TABLE ACCESS BY INDEX ROWID | DM_ACCT | 1 | 23 | 2 (0)| 00:00:01 |
|* 21 | INDEX UNIQUE SCAN | DM_ACCT_PK | 1 | | 1 (0)| 00:00:01 |
|* 22 | TABLE ACCESS FULL | DM_DT_QRY | 30 | 450 | 12 (9)| 00:00:01 |
| 23 | TABLE ACCESS BY INDEX ROWID | DM_FAC | 1 | 21 | 1 (0)| 00:00:01 |
|* 24 | INDEX UNIQUE SCAN | DM_FAC_UK | 1 | | 0 (0)| |
| 25 | TABLE ACCESS BY INDEX ROWID | DM_DRG_SVC_LN | 1 | 25 | 1 (0)| 00:00:01 |
|* 26 | INDEX UNIQUE SCAN | DM_DRG_SVC_LN_PK | 1 | | 0 (0)| |
Predicate Information (identified by operation id):
2 - filter((TO_DATE(:SYS_B_16,:SYS_B_17)<=TO_DATE(:SYS_B_18,:SYS_B_19) AND :SYS_B_00=:SYS_B_07))
5 - access("DM_ACCT"."DSCH_DT"="DM_DT__DSCH"."DT")
8 - access("DM_ORG_UNIT_DIV"."ORG_UNIT_GRP_SK"="DM_ORG_UNIT_GRP"."ORG_UNIT_GRP_SK")
9 - access("DM_ORG_UNIT_DIV"."ORG_UNIT_DIV_SK"="FACT_VISIT"."ORG_UNIT_DIV_SK")
10 - filter(("DM_ORG_UNIT_DIV"."DIV_CAT01_DESC"=:SYS_B_08 OR
"DM_ORG_UNIT_DIV"."DIV_CAT01_DESC"=:SYS_B_09))
11 - access("DM_DT_VISITSVC"."DT2_SK"="FACT_VISIT"."SVC_DT2_SK")
12 - filter(("DM_DT_VISITSVC"."DT">=TO_DATE(:SYS_B_16,:SYS_B_17) AND
"DM_DT_VISITSVC"."DT"<=TO_DATE(:SYS_B_18,:SYS_B_19)))
13 - filter("FACT_VISIT"."DEL_IND"=:SYS_B_01)
15 - filter(("DM_BILL_LOC"."BILL_LOC_NBR"=:SYS_B_14 OR "DM_BILL_LOC"."BILL_LOC_NBR"=:SYS_B_15))
16 - access("FACT_VISIT"."BILL_LOC_SK"="DM_BILL_LOC"."BILL_LOC_SK")
17 - filter(("DM_ORG_UNIT_GRP"."ARCHIVE_IND"=:SYS_B_00 AND
INTERNAL_FUNCTION("DM_ORG_UNIT_GRP"."EIS_LVL_1") AND
TO_NUMBER("DM_ORG_UNIT_GRP"."ORG_UNIT_GRP_NBR")<>:SYS_B_13))
18 - filter("DM_RSP_PTY"."RSP_PTY_TYPE_CD"=:SYS_B_02)
19 - access("DM_RSP_PTY"."CNR_PERS_ID_CURR"="FACT_VISIT"."CNR_PERS_ID_CURR")
filter("DM_RSP_PTY"."CNR_PERS_ID_CURR" IS NOT NULL)
20 - filter("DM_ACCT"."CURR_PAT_TYPE_CD"=:SYS_B_10)
21 - access("DM_RSP_PTY"."ACCT_SK"="DM_ACCT"."ACCT_SK")
22 - filter(("DM_DT__DSCH"."MTH_NBR"=:SYS_B_12 AND "DM_DT__DSCH"."YR_NBR"=:SYS_B_11))
24 - access("DM_ACCT"."FAC_CD"="DM_FAC"."FAC_CD")
26 - access("DM_ACCT"."DRG_SVC_LN_SK"="DM_DRG_SVC_LN"."DRG_SVC_LN_SK")
GOOD Plan
PLAN_TABLE_OUTPUT
SQL_ID 7y2m07bk7qwgx, child number 0
SELECT --q1 DM_FAC.FAC_NM, COUNT(DISTINCT DM_ACCT.ACCT_SK), DM_DRG_SVC_LN.DRG_SVC_LN_DESC FROM
DM_FAC, DM_ACCT, DM_DRG_SVC_LN, DM_ORG_UNIT_GRP, DM_ORG_UNIT_DIV, DM_DT_QRY DM_DT__DSCH,
DM_BILL_LOC, DM_DT_QRY DM_DT_VISITSVC, FACT_VISIT, DM_RSP_PTY WHERE (
DM_ORG_UNIT_GRP.ORG_UNIT_GRP_SK=DM_ORG_UNIT_DIV.ORG_UNIT_GRP_SK ) AND ( DM_ORG_UNIT_GRP.ARCHIVE_IND =
:"SYS_B_00" ) AND ( DM_DT_VISITSVC.DT2_SK=FACT_VISIT.SVC_DT2_SK ) AND (
DM_BILL_LOC.BILL_LOC_SK=FACT_VISIT.BILL_LOC_SK ) AND (
DM_ORG_UNIT_DIV.ORG_UNIT_DIV_SK=FACT_VISIT.ORG_UNIT_DIV_SK ) AND (
FACT_VISIT.DEL_IND=:"SYS_B_01" ) AND ( DM_RSP_PTY.ACCT_SK=DM_ACCT.ACCT_SK ) AND (
DM_RSP_PTY.RSP_PTY_TYPE_CD=:"SYS_B_02" ) AND ( DM_ACCT.FAC_CD=DM_FAC.FAC_CD ) AND (
DM_ACCT.DSCH_DT=DM_DT__DSCH.DT ) AND ( DM_ACCT.DRG_SVC_LN_SK=DM_DRG_SVC_LN.DRG_SVC_LN_SK )
Plan hash value: 1376284724
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | | | 22053 (100)| |
| 1 | SORT GROUP BY | | 2 | 348 | 22053 (3)| 00:00:57 |
|* 2 | FILTER | | | | | |
| 3 | NESTED LOOPS | | 2 | 348 | 22052 (3)| 00:00:57 |
| 4 | NESTED LOOPS | | 2 | 306 | 22050 (3)| 00:00:57 |
| 5 | NESTED LOOPS | | 2 | 256 | 22048 (3)| 00:00:57 |
|* 6 | HASH JOIN | | 4 | 456 | 22044 (3)| 00:00:57 |
|* 7 | HASH JOIN | | 8 | 784 | 22041 (3)| 00:00:57 |
|* 8 | HASH JOIN | | 21 | 1743 | 22035 (3)| 00:00:57 |
|* 9 | TABLE ACCESS FULL | DM_BILL_LOC | 2 | 16 | 3 (0)| 00:00:01 |
|* 10 | TABLE ACCESS BY INDEX ROWID | FACT_VISIT | 5 | 130 | 12 (0)| 00:00:01 |
| 11 | NESTED LOOPS | | 3453 | 252K| 22031 (3)| 00:00:57 |
| 12 | NESTED LOOPS | | 661 | 32389 | 15399 (4)| 00:00:40 |
| 13 | NESTED LOOPS | | 585 | 22230 | 13079 (5)| 00:00:34 |
|* 14 | TABLE ACCESS FULL | DM_DT_QRY | 30 | 450 | 12 (9)| 00:00:01 |
| 15 | TABLE ACCESS BY INDEX ROWID | DM_ACCT | 19 | 437 | 13079 (5)| 00:00:34 |
| 16 | BITMAP CONVERSION TO ROWIDS | | | | | |
| 17 | BITMAP AND | | | | | |
| 18 | BITMAP CONVERSION FROM ROWIDS| | | | | |
|* 19 | INDEX RANGE SCAN | DMACCT_DSCH_DT | 2098 | | 7 (0)| 00:00:01 |
| 20 | BITMAP CONVERSION FROM ROWIDS| | | | | |
|* 21 | INDEX RANGE SCAN | XSI_DMACCT01_CURRPATTYPCD | 2098 | | 421 (5)| 00:00:02 |
|* 22 | TABLE ACCESS BY INDEX ROWID | DM_RSP_PTY | 1 | 11 | 4 (0)| 00:00:01 |
|* 23 | INDEX RANGE SCAN | XSI_DMRSPPTY_PERS | 1 | | 3 (0)| 00:00:01 |
|* 24 | INDEX RANGE SCAN | FV_CNRPERSON_FK | 13 | | 2 (0)| 00:00:01 |
|* 25 | TABLE ACCESS FULL | DM_ORG_UNIT_DIV | 170 | 2550 | 5 (0)| 00:00:01 |
|* 26 | TABLE ACCESS FULL | DM_ORG_UNIT_GRP | 57 | 912 | 3 (0)| 00:00:01 |
|* 27 | TABLE ACCESS BY INDEX ROWID | DM_DT_QRY | 1 | 14 | 1 (0)| 00:00:01 |
|* 28 | INDEX UNIQUE SCAN | DM_DT2_QRY_UK | 1 | | 0 (0)| |
| 29 | TABLE ACCESS BY INDEX ROWID | DM_DRG_SVC_LN | 1 | 25 | 1 (0)| 00:00:01 |
|* 30 | INDEX UNIQUE SCAN | DM_DRG_SVC_LN_PK | 1 | | 0 (0)| |
| 31 | TABLE ACCESS BY INDEX ROWID | DM_FAC | 1 | 21 | 1 (0)| 00:00:01 |
|* 32 | INDEX UNIQUE SCAN | DM_FAC_UK | 1 | | 0 (0)| |
Predicate Information (identified by operation id):
2 - filter((TO_DATE(:SYS_B_16,:SYS_B_17)<=TO_DATE(:SYS_B_18,:SYS_B_19) AND :SYS_B_00=:SYS_B_07))
6 - access("DM_ORG_UNIT_DIV"."ORG_UNIT_GRP_SK"="DM_ORG_UNIT_GRP"."ORG_UNIT_GRP_SK")
7 - access("DM_ORG_UNIT_DIV"."ORG_UNIT_DIV_SK"="FACT_VISIT"."ORG_UNIT_DIV_SK")
8 - access("FACT_VISIT"."BILL_LOC_SK"="DM_BILL_LOC"."BILL_LOC_SK")
9 - filter(("DM_BILL_LOC"."BILL_LOC_NBR"=:SYS_B_14 OR "DM_BILL_LOC"."BILL_LOC_NBR"=:SYS_B_15))
10 - filter("FACT_VISIT"."DEL_IND"=:SYS_B_01)
14 - filter(("DM_DT__DSCH"."MTH_NBR"=:SYS_B_12 AND "DM_DT__DSCH"."YR_NBR"=:SYS_B_11))
19 - access("DM_ACCT"."DSCH_DT"="DM_DT__DSCH"."DT")
21 - access("DM_ACCT"."CURR_PAT_TYPE_CD"=:SYS_B_10)
22 - filter("DM_RSP_PTY"."CNR_PERS_ID_CURR" IS NOT NULL)
23 - access("DM_RSP_PTY"."ACCT_SK"="DM_ACCT"."ACCT_SK" AND "DM_RSP_PTY"."RSP_PTY_TYPE_CD"=:SYS_B_02)
24 - access("DM_RSP_PTY"."CNR_PERS_ID_CURR"="FACT_VISIT"."CNR_PERS_ID_CURR")
25 - filter(("DM_ORG_UNIT_DIV"."DIV_CAT01_DESC"=:SYS_B_08 OR "DM_ORG_UNIT_DIV"."DIV_CAT01_DESC"=:SYS_B_09))
26 - filter(("DM_ORG_UNIT_GRP"."ARCHIVE_IND"=:SYS_B_00 AND INTERNAL_FUNCTION("DM_ORG_UNIT_GRP"."EIS_LVL_1") AND
TO_NUMBER("DM_ORG_UNIT_GRP"."ORG_UNIT_GRP_NBR")<>:SYS_B_13))
27 - filter(("DM_DT_VISITSVC"."DT">=TO_DATE(:SYS_B_16,:SYS_B_17) AND
"DM_DT_VISITSVC"."DT"<=TO_DATE(:SYS_B_18,:SYS_B_19)))
28 - access("DM_DT_VISITSVC"."DT2_SK"="FACT_VISIT"."SVC_DT2_SK")
30 - access("DM_ACCT"."DRG_SVC_LN_SK"="DM_DRG_SVC_LN"."DRG_SVC_LN_SK")
32 - access("DM_ACCT"."FAC_CD"="DM_FAC"."FAC_CD")
-
Query regarding Partition table Explain plan
Hello,
We are amidst a tuning activity, wherein a large table has been partitioned for better administration. During testing, I was analyzing the explain plans for long running sql's and found a piece that I was unable to understand. The PSTART and PSTOP columns show ROWID as its value, which in normal partition pruning scenario be the Partition number or the KEY. I tried to look around for this issue but did not get enough information. Can anybody help me of what it means? Also, if there is a good explanation of the same, it will be extremely helpful.
The snippet from explain plan looks like:
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop |
7 | TABLE ACCESS BY GLOBAL INDEX ROWID| XXXXXXXXXXXXXXXXXXXX | 43874 | 9083K| | 1386 (1)| 00:00:17 | ROWID | ROWID |
On another similar query it looks like:
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop |
| 6 | TABLE ACCESS BY GLOBAL INDEX ROWID| XXXXXXXXXXXXXX | 22455 | 4648K| | 456 (1)| 00:00:06 | 9 | 9 |
I have another query with regards to the Partition tables. Does it, require/benefit if, the Indexes to be in partitioned mode? I tried to read about it but did not get a conclusive evidence. I am trying to test it and post here the outcome, but if anybody has experience of working with it, it would be great to have some advice.
Oracle Version:- 10.2.0.4
Regards,
Purvesh.Hi Purvesh.
Great explanation and example on this this topic...
Ask Tom &quot;explain plan on range-partitioned table&quot;
Hope this help. -
Running total required but with different timing
Hi All:
I am using Oracle9i Enterprise Edition Release 9.2.0.6.0
I want to write a query to display the statistics report with running total.
I have written following query that return last 60 minutes activities.
SELECT se.tserv_id,
sum(decode(eu.category,'I',1,0)) Imp,
sum(decode(eu.category,'E',1,0)) Exp,
count(*) Total
FROM service_events se, equipment_uses eu
WHERE se.performed BETWEEN trunc(sysdate-60/1440,'mi')
AND trunc(sysdate,'mi')
AND se.tserv_id IN ('EXM','GROUNDED')
AND eu.gkey = se.equse_gkey
AND eu.category IN ('I','E')
GROUP BY se.tserv_id;
now I want to write a query that shows me the result of above query and running total as well
But the different between current activity and running total is as follows
Current Activity = Last 60 minutes activity
Running Total = Total activities from the 08:00 am till sysdate.
for example if this query executed on 11:00 am then the current activity values must be from 10:00 am to 11:00 am and the running total values must be from 08:00 am to 11:00 am
The reason for running total starts at 08:00 am is that the shift starts from 08:00 am to next day 07:59 am.
Can I write one single query for this?
Similarly running total values must be start from last day 08:00 am to current date and time when I executed this query from 00:00 to 08:00 (12 midnight to 8am)
if difficult then plz let me know that how can I find that if the time is from 00 hrs to 08 hrs then start time must be the last date 08:00 am to the current date and time.
Thanks
HassanDear Frnak
Thanks for your reply and help
Its really did what I want
I mean to say that the result format is correct but the value of Total_day column is not correct.
Following is the sample data from 19-Jun-2008 08:00 AM to 20-JUN-2008 08:00 AM
TSERV_ID EQUSE_GKEY PERFORMED
===============================================
EXM 5188958 19-Jun-2008 8:00:32 AM
EXM 5185586 19-Jun-2008 9:03:34 AM
EXM 5181960 19-Jun-2008 9:03:35 AM
EXM 5173333 19-Jun-2008 9:03:35 AM
EXM 5188263 19-Jun-2008 9:08:49 AM
GROUNDED 5174055 19-Jun-2008 9:10:29 AM
GROUNDED 5152887 19-Jun-2008 9:10:29 AM
GROUNDED 5187512 19-Jun-2008 9:10:29 AM
GROUNDED 5196303 19-Jun-2008 9:27:41 AM
EXM 5196370 19-Jun-2008 9:29:50 AM
EXM 5172045 19-Jun-2008 10:01:23 AM
GROUNDED 5196269 19-Jun-2008 11:11:29 AM
GROUNDED 5200219 19-Jun-2008 11:24:39 AM
GROUNDED 5185246 19-Jun-2008 12:06:30 PM
GROUNDED 5190134 19-Jun-2008 12:09:27 PM
GROUNDED 5190475 19-Jun-2008 12:09:27 PM
GROUNDED 5156065 19-Jun-2008 12:26:49 PM
GROUNDED 5132287 19-Jun-2008 1:56:44 PM
EXM 5189203 19-Jun-2008 2:29:17 PM
EXM 5180158 19-Jun-2008 3:27:03 PM
EXM 5149310 19-Jun-2008 3:37:31 PM
EXM 5196303 19-Jun-2008 3:42:48 PM
EXM 5192768 19-Jun-2008 4:03:51 PM
EXM 5174055 19-Jun-2008 4:14:23 PM
EXM 5200231 19-Jun-2008 4:45:51 PM
EXM 5157151 19-Jun-2008 4:51:06 PM
EXM 5159930 19-Jun-2008 5:01:36 PM
EXM 5185237 19-Jun-2008 5:01:37 PM
EXM 5195434 19-Jun-2008 5:01:37 PM
EXM 5152887 19-Jun-2008 5:06:49 PM
EXM 5196269 19-Jun-2008 5:06:49 PM
EXM 5187512 19-Jun-2008 5:17:26 PM
EXM 5190134 19-Jun-2008 5:59:24 PM
GROUNDED 5101919 19-Jun-2008 6:44:36 PM
GROUNDED 5101918 19-Jun-2008 6:44:37 PM
GROUNDED 5101913 19-Jun-2008 6:44:37 PM
EXM 5185735 19-Jun-2008 6:46:38 PM
GROUNDED 5195475 19-Jun-2008 6:47:11 PM
GROUNDED 5195361 19-Jun-2008 6:47:12 PM
EXM 5132608 19-Jun-2008 7:02:23 PM
GROUNDED 5195334 19-Jun-2008 7:10:32 PM
GROUNDED 5190558 19-Jun-2008 7:10:32 PM
EXM 5183029 19-Jun-2008 7:33:53 PM
EXM 5183480 19-Jun-2008 7:39:12 PM
EXM 5189566 19-Jun-2008 8:00:11 PM
EXM 5181825 19-Jun-2008 8:15:57 PM
EXM 5183537 19-Jun-2008 8:15:57 PM
EXM 5180210 19-Jun-2008 9:08:27 PM
GROUNDED 5193136 19-Jun-2008 9:58:23 PM
EXM 5171510 19-Jun-2008 10:21:59 PM
EXM 5185615 19-Jun-2008 10:48:14 PM
EXM 5184737 19-Jun-2008 10:53:29 PM
EXM 5195475 19-Jun-2008 11:51:16 PM
EXM 5195476 20-Jun-2008 12:01:46 AM
EXM 5190558 20-Jun-2008 12:12:17 AM
EXM 5196473 20-Jun-2008 12:54:19 AM
EXM 5183204 20-Jun-2008 1:20:34 AM
GROUNDED 5192844 20-Jun-2008 1:28:24 AM
GROUNDED 5174238 20-Jun-2008 1:28:24 AM
GROUNDED 5193127 20-Jun-2008 1:28:24 AM
GROUNDED 5185794 20-Jun-2008 1:29:09 AM
GROUNDED 5192895 20-Jun-2008 3:04:23 AM
GROUNDED 5193039 20-Jun-2008 3:04:23 AM
GROUNDED 5195447 20-Jun-2008 3:04:23 AM
GROUNDED 5190228 20-Jun-2008 3:04:24 AM
GROUNDED 5179370 20-Jun-2008 3:04:24 AM
GROUNDED 5190289 20-Jun-2008 3:04:24 AM
GROUNDED 5174065 20-Jun-2008 3:04:24 AM
GROUNDED 5192862 20-Jun-2008 5:04:42 AM
GROUNDED 5199903 20-Jun-2008 5:04:42 AM
EXM 5178176 20-Jun-2008 6:30:29 AM
EXM 5185161 20-Jun-2008 6:46:14 AM
EXM 5180226 20-Jun-2008 6:46:14 AM
GROUNDED 5202026 20-Jun-2008 7:03:14 AM
EXM 5101912 20-Jun-2008 7:07:14 AM
GROUNDED 5176763 20-Jun-2008 7:25:27 AM
GROUNDED 5185494 20-Jun-2008 7:25:27 AM
EXM 5185295 20-Jun-2008 7:38:46 AM
EXM 5173837 20-Jun-2008 7:49:15 AM
GKEY CATEGORY
=================
5101912 I
5101913 I
5101918 I
5101919 I
5132287 I
5132608 I
5149310 I
5152887 I
5156065 I
5157151 I
5159930 I
5171510 I
5172045 I
5173333 I
5173837 I
5174055 I
5174065 I
5174238 I
5176763 I
5178176 I
5179370 I
5180158 I
5180210 I
5180226 I
5181825 I
5181960 I
5183029 I
5183204 I
5183480 I
5183537 I
5184737 I
5185161 I
5185237 I
5185246 I
5185295 I
5185494 I
5185586 I
5185615 I
5185735 I
5185794 I
5187512 I
5188263 I
5188958 I
5189203 I
5189566 I
5190134 I
5190228 I
5190289 I
5190475 I
5190558 I
5192768 I
5192844 I
5192862 I
5192895 I
5193039 I
5193127 I
5193136 I
5195334 I
5195361 I
5195434 I
5195447 I
5195475 I
5195476 I
5196269 I
5196303 I
5196370 I
5196473 I
5199903 I
5200219 E
5200231 E
5202026 EAnd I used the same query suggested by you.
WITH s AS(
SELECT se.tserv_id , eu.category ,
CASE
WHEN se.performed BETWEEN
to_date('&target_dt','DD-MON-RRRR HH24:MI') - (1/24)
AND to_date('&target_dt','DD-MON-RRRR HH24:MI')
THEN 1
ELSE 0
END AS in_hour ,
CASE
WHEN TRUNC (se.performed - (8/24)) = TRUNC (to_date('&target_dt','DD-MON-RRRR HH24:MI')
- (8/24))
THEN 1
ELSE 0
END AS in_day
FROM service_events se , equipment_uses eu
WHERE eu.gkey = se.equse_gkey
AND eu.category IN ('I', 'E')
AND se.tserv_id in ('EXM','GROUNDED')
SELECT tserv_id,
SUM (DECODE (category, 'I', in_hour)) AS imp_hour,
SUM (DECODE (category, 'E', in_hour)) AS exp_hour,
SUM (in_hour) AS total_hour,
SUM (in_day) AS total_day
FROM s
GROUP BY tserv_idNow you have the sample data for almost 24 hours
Let me clear it again
When I executed this query at 20-JUN-2008 09:00 AM it gives me following result (that is accurate)
TSERV_ID IMP_HOUR EXP_HOUR TOTAL_HOUR TOTAL_DAY
EXM 2 0 2 3
GROUNDED 1 0 1 8When I executed this query between 20-JUN-2008 00:00 to 20-JUN-2008 08:00
then system must show the Total_Day value from 19-JUN-2008 08:00 to current date and time. e.g
I executed this query at 20-JUN-2008 06:00 AM it gives me following result:
TSERV_ID IMP_HOUR EXP_HOUR TOTAL_HOUR TOTAL_DAY
EXM 0 0 0 44
GROUNDED 2 0 2 35Now here you can see that the value of Total_Day is not as accurate as I required:
EXM = 44 and GROUNDED = 35
these values are between 19-JUN-2008 00:00 to 20-JUN-2008 06:00 (that is wrong in my case)
The values of total_day should be as follows as 8 hours from 00:00 to 07:59 AM fall in the shift of 18-JUN-2008 not in 19-JUN-2008
From 19-JUN-2008 08:00 to 20-JUN-2008 06:00
EXM: 38
GROUNDED: 32
Plz note that this result is required because in our company the shift starts from 08:00 AM and ends 07:59 AM next day
I hope you will be more clear now and there is no confusion anymore.
Plz let me know if you still confused.
Brgs,
Maybe you are looking for
-
Itunes has stopped working on windows 8 - 64 bit
Itunes works fine until I try to access the store. Then I get the message and windows of course fails to find a solution.
-
Custom AddOn and Payment Engine causes table lock
Hi, i run with 2 customers in the same problem with different add-ons. After the customer saved a document via the standard SBO GUI the corresponding table will be locked in the database until the SBO-Client client was killed. The only thing witch th
-
Order Qty,GR Qty & Confirmed Qty in a single report
Is there any standard report is there to see Order Qty,GR Qty & Confirmed Qty in a single sheet Most of the LIS reprts like MCPM,MCP1 etc.. giving either Gr qty or Confirmed qty. Your Valuable inputs required
-
Execute Process Chain Using ABAP
Hi All, Is there any standard ABAP Code or Function Module through which we can execute the Process Chain Manually. Regards, Anuja
-
Can any one advise me on what ways to go to save my sites that are redundant on the next period but should be on line again if needed. I know that FTP, nowadays SFTP can be used for that, trouble is that I forgot the login convention. Can you please