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 6th, 2006, 09:09 AM
Authorized User
 
Join Date: Jan 2006
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default bindvariable in TOAD

Hi,
   If i run the following query in toad,it is going thro all indexes except one table access full.
   In place of bind variable,if i give the variable directly it is not going thro any table access full.
   If i try same two things in SQLPlus,it is not going thro any table access full.
   It is only happening in TOAD.Can any one tell me the reason or give me any code modifications in TOAD.

The Query as follows:
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 first_name LIKE UPPER(:QueryStrFN)
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:
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop

SELECT STATEMENT Optimizer Mode=CHOOSE 999 4108
  SORT ORDER BY 999 52 K 4108
    COUNT STOPKEY
      HASH JOIN 40 K 2 M 3659
        HASH JOIN 40 K 1 M 1698
          TABLE ACCESS BY INDEX ROWID CNH_CALMS2APP.CUSTOMERS_PERSONAL 39 K 957 K 1068
            INDEX RANGE SCAN CNH_CALMS2APP.INDX_FIRST_NAME 7 K 20
          TABLE ACCESS BY INDEX ROWID CNH_CALMS2APP.CUSTOMERS_ADDRESS 162 K 1 M 413
            INDEX RANGE SCAN CNH_CALMS2APP.INDX_CUST_COUNTRY_CODE 8 13
        TABLE ACCESS FULL CNH_CALMS2APP.CUSTOMERS 399 K 6 M 1411


Bind variable with variable name:
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 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:
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop

SELECT STATEMENT Optimizer Mode=CHOOSE 34 159
  SORT ORDER BY 34 1 K 159
    COUNT STOPKEY
      NESTED LOOPS 34 1 K 159
        NESTED LOOPS 33 1 K 93
          TABLE ACCESS BY INDEX ROWID CNH_CALMS2APP.CUSTOMERS_PERSONAL 33 825 27
            INDEX RANGE SCAN CNH_CALMS2APP.INDX_FIRST_NAME 33 3
          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


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




All times are GMT -4. The time now is 04:27 PM.


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