Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 6th, 2006, 09:09 AM
Authorized User
 
Join Date: Jan 2006
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











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