![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, When tracing SQL statements from SQLPLUS to see consistent gets and such, if the query contains bind variables or constants, how do you 'emulate' that in SQLPLUS and perform the trace? *Here is an example: This is in one of our stored procedures. *It does 5500 consistent gets. *I want to try and bring that down, but, I'm thinking I can't because of the literals. *If I change those to bind variables as well as the 237 constant, how can I trace that from SQLPLUS? SELECT subgroup_id, max_allowed_subscr, allow_new_subscriptions, priority FROM (SELECT ts.subgroup_id, max_allowed_subscr, allow_new_subscriptions, priority, COUNT(ts.subgroup_id) * * * OVER (PARTITION BY ts.subgroup_id, ts.newsletter_id) number_in_group, ROW_NUMBER() * * * OVER (PARTITION BY ts.subgroup_id, ts.newsletter_id ORDER BY priority) rnum * * * FROM engine.ts_subgroups ts, engine.ts_customers tc, engine.customer_order co, * * * * * *engine.order_line ol, engine.product p * * * WHERE ts.subgroup_id * = tc.subgroup_id * * * * AND tc.customer_id * = co.customer_id * * * * AND co.order_id * * *= ol.order_id * * * * AND ol.product_id * *= p.product_id * * * * AND ol.status IN ('Active','Pending') * * * * AND p.subproduct_id *= 237 * * * * AND ts.newsletter_id = 237) WHERE rnum = 1; |
#3
| |||
| |||
|
|
On Nov 19, 8:45*am, The Magnet <a... (AT) unsu (DOT) com> wrote: Hi, When tracing SQL statements from SQLPLUS to see consistent gets and such, if the query contains bind variables or constants, how do you 'emulate' that in SQLPLUS and perform the trace? *Here is an example: This is in one of our stored procedures. *It does 5500 consistent gets. *I want to try and bring that down, but, I'm thinking I can't because of the literals. *If I change those to bind variables as well as the 237 constant, how can I trace that from SQLPLUS? SELECT subgroup_id, max_allowed_subscr, allow_new_subscriptions, priority FROM (SELECT ts.subgroup_id, max_allowed_subscr, allow_new_subscriptions, priority, COUNT(ts.subgroup_id) * * * OVER (PARTITION BY ts.subgroup_id, ts.newsletter_id) number_in_group, ROW_NUMBER() * * * OVER (PARTITION BY ts.subgroup_id, ts.newsletter_id ORDER BY priority) rnum * * * FROM engine.ts_subgroups ts, engine.ts_customers tc, engine.customer_order co, * * * * * *engine.order_line ol, engine.product p * * * WHERE ts.subgroup_id * = tc.subgroup_id * * * * AND tc.customer_id * = co.customer_id * * * * AND co.order_id * * *= ol.order_id * * * * AND ol.product_id * *= p.product_id * * * * AND ol.status IN ('Active','Pending') * * * * AND p.subproduct_id *= 237 * * * * AND ts.newsletter_id = 237) WHERE rnum = 1; Never tried it myself, but seehttp://www.oracle.com/technology/support/tech/sql_plus/htdocs/sub_var... Some people have blogged about this, so a google may turn that up. jg -- @home.com is bogus. "You're a little hostile, Joel." - Ralph Garman, giving Joel McHale a hard time in a radio interview. |
#4
| ||||||
| ||||||
|
|
Hi, When tracing SQL statements from SQLPLUS to see consistent gets and such, if the query contains bind variables or constants, how do you 'emulate' that in SQLPLUS and perform the trace? *Here is an example: This is in one of our stored procedures. *It does 5500 consistent gets. *I want to try and bring that down, but, I'm thinking I can't because of the literals. *If I change those to bind variables as well as the 237 constant, how can I trace that from SQLPLUS? SELECT subgroup_id, max_allowed_subscr, allow_new_subscriptions, priority FROM (SELECT ts.subgroup_id, max_allowed_subscr, allow_new_subscriptions, priority, COUNT(ts.subgroup_id) * * * OVER (PARTITION BY ts.subgroup_id, ts.newsletter_id) number_in_group, ROW_NUMBER() * * * OVER (PARTITION BY ts.subgroup_id, ts.newsletter_id ORDER BY priority) rnum * * * FROM engine.ts_subgroups ts, engine.ts_customers tc, engine.customer_order co, * * * * * *engine.order_line ol, engine.product p * * * WHERE ts.subgroup_id * = tc.subgroup_id * * * * AND tc.customer_id * = co.customer_id * * * * AND co.order_id * * *= ol.order_id * * * * AND ol.product_id * *= p.product_id * * * * AND ol.status IN ('Active','Pending') * * * * AND p.subproduct_id *= 237 * * * * AND ts.newsletter_id = 237) WHERE rnum = 1; |
|
Id |Operation |Name | Rows | Bytes | Cost (%CPU)| Time | |
|
0|SELECT STATEMENT | | | | 52 (100)| | * 1| FILTER | | | | | * 2| HASH JOIN | | 99 | 10692 | 52 (2)| 00:00:01 | * 3| TABLE ACCESS FULL |T3 | 100 | 400 | 47 (0)| 00:00:01 | 4| TABLE ACCESS BY INDEX ROWID|T4 | 100 | 10400 | 4 (0)| 00:00:01 | * 5| INDEX RANGE SCAN |IND_T4 | 100 | | 2 (0)| 00:00:01 | |
|
Id | Operation | Name | Starts | E-Rows | A- Rows | |
|
0 | SELECT STATEMENT | | 1 | | 10000 | * 1 | FILTER | | 1 | | 10000 | * 2 | HASH JOIN | | 1 | 99 | 10000 | * 3 | TABLE ACCESS FULL | T3 | 1 | 100 | 10000 | 4 | TABLE ACCESS BY INDEX ROWID| T4 | 1 | 100 | 10000 | * 5 | INDEX RANGE SCAN | IND_T4 | 1 | 100 | 10000 | |
|
A-Time | Buffers | Reads | OMem | 1Mem | Used-Mem | ------------------------------------------------------------ 00:00:00.07 | 1666 | 355 | | | | 00:00:00.07 | 1666 | 355 | | | | 00:00:00.07 | 1666 | 355 | 1517K| 1517K| 1882K (0)| 00:00:00.07 | 158 | 155 | | | | 00:00:00.01 | 1508 | 200 | | | | 00:00:00.01 | 687 | 32 | | | | ------------------------------------------------------------ |
![]() |
| Thread Tools | |
| Display Modes | |
| |