Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 2nd, 2006, 05:06 AM
Authorized User
 
Join Date: Jan 2006
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default explain plan with bind variable

Hi,
  Below is the code where i am encountering problems.If i give bindvariable instead of travis in the below query,it is reflecting in the explain plan and so execution time also increasing.
I am sending you the query and explain plans.
How to get the same explain plan with bind variable.

Can any one help me in this reg ASAP..


Query :
SELECT cp.customer_id
FROM CUSTOMERS_PERSONAL cp, CUSTOMERS_ADDRESS ca ,CUSTOMERS c
WHERE ca.customer_id = cp.customer_id
AND ROWNUM < 1000
AND (ca.address_type = 'SH')
AND ca.country_code = 'US'
AND cp.first_name LIKE UPPER('travis%')
AND NVL(c.is_master,'Y')='Y'
AND c.customer_id = cp.customer_id
AND c.customer_code IS NOT NULL
ORDER BY cp.last_name, cp.first_name, cp.middle_name, cp.name_suffix

Explain Plan with first_name as travis:

Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop

SELECT STATEMENT Optimizer Mode=CHOOSE 34 135
  SORT ORDER BY 34 1 K 135
    COUNT STOPKEY
      NESTED LOOPS 34 1 K 135
        NESTED LOOPS 33 1 K 69
          TABLE ACCESS BY INDEX ROWID CNH_CALMS2APP.CUSTOMERS_PERSONAL 33 825 3
            INDEX RANGE SCAN CNH_CALMS2APP.INDX_FIRST_NAME 33 2
          TABLE ACCESS BY INDEX ROWID CNH_CALMS2APP.CUSTOMERS 1 17 2
            INDEX UNIQUE SCAN CNH_CALMS2APP.XPKCUSTOMERS 3 1
        TABLE ACCESS BY INDEX ROWID CNH_CALMS2APP.CUSTOMERS_ADDRESS 1 12 2
          INDEX UNIQUE SCAN CNH_CALMS2APP.XAK1_CUSTOMERS_ADDRESS 8 1

Explain Plan with first_name as bind-variable(:QueryStrFN):

Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop

SELECT STATEMENT Optimizer Mode=CHOOSE 999 4936
  SORT ORDER BY 999 52 K 4936
    COUNT STOPKEY
      HASH JOIN 40 K 2 M 4487
        HASH JOIN 40 K 1 M 2526
          TABLE ACCESS BY INDEX ROWID CNH_CALMS2APP.CUSTOMERS_PERSONAL 39 K 957 K 10
            INDEX RANGE SCAN CNH_CALMS2APP.INDX_FIRST_NAME 7 K 2
          TABLE ACCESS FULL CNH_CALMS2APP.CUSTOMERS_ADDRESS 162 K 1 M 2299
        TABLE ACCESS FULL CNH_CALMS2APP.CUSTOMERS 399 K 6 M 1411





Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Execution Plan of a Query asuni SQL Server 2005 0 August 6th, 2008 03:42 AM
How to delete a wizard plan... RinoDM SQL Server 2005 0 July 18th, 2007 10:13 AM
how to use v$sqlarea to see explain plan ramanadyv SQL Language 1 April 5th, 2006 08:14 AM
bind variable htummala Oracle 1 February 15th, 2005 05:32 AM



All times are GMT -4. The time now is 12:11 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.