Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: select with Null

RE: select with Null

From: Koivu, Lisa <lkoivu_at_qode.com>
Date: Wed, 22 Nov 2000 14:15:22 -0500
Message-Id: <10688.122752@fatcity.com>


This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible.

------_=_NextPart_001_01C054B8.9354A4CC

Content-Type: text/plain;

        charset="iso-8859-1"

The NVL() will disable the index. See below.

SQL> desc b_list
 Name


 ID                  NOT NULL           
 USER_ID             NOT NULL
 NAME                NOT NULL           
 EXPDATE                        

SQL> SELECT INDEX_NAME, COLUMN_NAME FROM USER_IND_COLUMNS   2 WHERE TABLE_NAME = 'B_LIST';

INDEX_NAME                     COLUMN_NAME

------------------------------ ------------------------------
BL_IDX EXPDATE

  1 select /*+ index (bin_list bl_idx) */   2 count(*) from b_list
  3* where expdate > sysdate - 10
SQL> /   COUNT(*)


       999

Execution Plan


   0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=9)    1 0 SORT (AGGREGATE)

   2    1     INDEX (RANGE SCAN) OF 'BL_IDX' (NON-UNIQUE) (Cost=2 Card
          =70 Bytes=630)


  1 select /*+ index (bin_list bl_idx) */   2 count(*) from b_list
  3* where nvl(expdate,sysdate ) > sysdate - 10 SQL> /   COUNT(*)


      3062

Execution Plan


   0 SELECT STATEMENT Optimizer=CHOOSE (Cost=3 Card=1 Bytes=9)    1 0 SORT (AGGREGATE)

   2    1     TABLE ACCESS (FULL) OF 'BIN_LIST' (Cost=3 Card=70 Bytes=
          630)

Lisa Rutland Koivu
Oracle Database Administrator
Qode.com
4850 North State Road 7
Suite G104
Fort Lauderdale, FL 33319

V: 954.484.3191, x174
F: 954.484.2933 
C: 954.658.5849

http://www.qode.com

"The information contained herein does not express the opinion or position of Qode.com and cannot be attributed to or made binding upon Qode.com."

-----Original Message-----

From: Marcos.Vera_at_msconsultores.com.pe
[mailto:Marcos.Vera_at_msconsultores.com.pe] Sent: Wednesday, November 22, 2000 1:16 PM To: Multiple recipients of list ORACLE-L Subject: Re: select with Null

select d.discount_type

   from discount d
 where (NVL(d.company_code,'XX') = 'XX')

     and (NVL(d.operator_code,'YY') = 'YY')

Raj Gopalan <raj.gopalan_at_netdecisions.co.uk> on 22/11/2000 12:35:24 PM

Please respond to ORACLE-L_at_fatcity.com      

                                                              
                                                              
                                                              
 To:      Multiple recipients of list ORACLE-L                
          <ORACLE-L_at_fatcity.com>                              
                                                              
 cc:      (bcc: Marcos Vera/M&S Consultores/51)               
                                                              
                                                              
                                                              
 Subject: select with Null                                    
                                                              







Hello list,

I have a query

select d.discount_type

   from discount d
 where (d.company_code = 'XX' or

            d.company_code is null)
     and (d.operator_code = 'YY' or
             d.operator_code is null)

Apparently, oracle is not using the index since I am using IS NULL. But the functional requirement is such that the query need to consider records even if company_code, Operator_code ,... is null.

Any thoughts on how do I modify this query so that the index is being used.

TIA Raj

--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Raj Gopalan
  INET: raj.gopalan_at_netdecisions.co.uk

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists

--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: INET: Marcos.Vera_at_msconsultores.com.pe Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
------_=_NextPart_001_01C054B8.9354A4CC
Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Diso-8859-1"> <META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version = 5.5.2650.12"> <TITLE>RE: select with Null</TITLE> </HEAD> <BODY> <P><FONT SIZE=3D2>The NVL() will disable the index.&nbsp; See = below.</FONT> </P> <P><FONT SIZE=3D2>SQL&gt; desc b_list</FONT> <BR><FONT = SIZE=3D2>&nbsp;Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp= ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp= ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT> <BR><FONT SIZE=3D2>&nbsp;-----------------------------</FONT> <BR><FONT = SIZE=3D2>&nbsp;ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&= nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NOT = NULL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = </FONT> <BR><FONT = SIZE=3D2>&nbsp;USER_ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n= bsp;&nbsp;&nbsp;&nbsp; NOT NULL</FONT> <BR><FONT = SIZE=3D2>&nbsp;NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp= ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NOT = NULL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = </FONT> <BR><FONT = SIZE=3D2>&nbsp;EXPDATE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n= bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n= bsp;&nbsp;&nbsp; </FONT> </P> <P><FONT SIZE=3D2>SQL&gt; SELECT INDEX_NAME, COLUMN_NAME FROM = USER_IND_COLUMNS</FONT> <BR><FONT SIZE=3D2>&nbsp; 2&nbsp;&nbsp; WHERE TABLE_NAME =3D = 'B_LIST';</FONT> </P> <P><FONT = SIZE=3D2>INDEX_NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp= ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = COLUMN_NAME</FONT> <BR><FONT SIZE=3D2>------------------------------ =
------------------------------</FONT>
<BR><FONT = SIZE=3D2>BL_IDX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp; EXPDATE</FONT> </P> <BR> <P><FONT SIZE=3D2>&nbsp; 1&nbsp; select /*+ index (bin_list bl_idx) = */</FONT> <BR><FONT SIZE=3D2>&nbsp; 2&nbsp; count(*) from b_list</FONT> <BR><FONT SIZE=3D2>&nbsp; 3* where expdate &gt; sysdate - 10</FONT> <BR><FONT SIZE=3D2>SQL&gt; /</FONT> </P> <P><FONT SIZE=3D2>&nbsp; COUNT(*)</FONT> <BR><FONT SIZE=3D2>----------</FONT> <BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 999</FONT> </P> <BR> <P><FONT SIZE=3D2>Execution Plan</FONT> <BR><FONT = SIZE=3D2>----------------------------------------------------------</FON= T> <BR><FONT SIZE=3D2>&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT = STATEMENT Optimizer=3DCHOOSE (Cost=3D2 Card=3D1 Bytes=3D9)</FONT> <BR><FONT SIZE=3D2>&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; SORT = (AGGREGATE)</FONT> <BR><FONT SIZE=3D2>&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp; = 1&nbsp;&nbsp;&nbsp;&nbsp; INDEX (RANGE SCAN) OF 'BL_IDX' (NON-UNIQUE) = (Cost=3D2 Card</FONT> <BR><FONT = SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =3D70 = Bytes=3D630)</FONT> </P> <BR> <P><FONT SIZE=3D2>&nbsp; 1&nbsp; select /*+ index (bin_list bl_idx) = */</FONT> <BR><FONT SIZE=3D2>&nbsp; 2&nbsp; count(*) from b_list</FONT> <BR><FONT SIZE=3D2>&nbsp; 3* where nvl(expdate,sysdate ) &gt; sysdate - = 10</FONT> <BR><FONT SIZE=3D2>SQL&gt; /</FONT> </P> <P><FONT SIZE=3D2>&nbsp; COUNT(*)</FONT> <BR><FONT SIZE=3D2>----------</FONT> <BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3062</FONT> </P> <BR> <P><FONT SIZE=3D2>Execution Plan</FONT> <BR><FONT = SIZE=3D2>----------------------------------------------------------</FON= T> <BR><FONT SIZE=3D2>&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT = STATEMENT Optimizer=3DCHOOSE (Cost=3D3 Card=3D1 Bytes=3D9)</FONT> <BR><FONT SIZE=3D2>&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; SORT = (AGGREGATE)</FONT> <BR><FONT SIZE=3D2>&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp; = 1&nbsp;&nbsp;&nbsp;&nbsp; TABLE ACCESS (FULL) OF 'BIN_LIST' (Cost=3D3 = Card=3D70 Bytes=3D</FONT> <BR><FONT = SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 630)</FONT> </P> <P><FONT SIZE=3D2>Lisa Rutland Koivu</FONT> <BR><FONT SIZE=3D2>Oracle Database Administrator</FONT> <BR><FONT SIZE=3D2>Qode.com</FONT> <BR><FONT SIZE=3D2>4850 North State Road 7</FONT> <BR><FONT SIZE=3D2>Suite G104</FONT> <BR><FONT SIZE=3D2>Fort Lauderdale, FL&nbsp; 33319</FONT> </P> <P><FONT SIZE=3D2>V: 954.484.3191, x174</FONT> <BR><FONT SIZE=3D2>F: 954.484.2933 </FONT> <BR><FONT SIZE=3D2>C: 954.658.5849</FONT> <BR><FONT SIZE=3D2><A HREF=3D"http://www.qode.com" = TARGET=3D"_blank">http://www.qode.com</A></FONT> </P> <P><FONT SIZE=3D2>&quot;The information contained herein does not = express the opinion or position of Qode.com and cannot be attributed to = or made binding upon Qode.com.&quot;</FONT></P> <BR> <P><FONT SIZE=3D2>-----Original Message-----</FONT> <BR><FONT SIZE=3D2>From: Marcos.Vera_at_msconsultores.com.pe</FONT> <BR><FONT SIZE=3D2>[<A = HREF=3D"mailto:Marcos.Vera_at_msconsultores.com.pe">mailto:Marcos.Vera_at_msco= nsultores.com.pe</A>]</FONT> <BR><FONT SIZE=3D2>Sent: Wednesday, November 22, 2000 1:16 PM</FONT> <BR><FONT SIZE=3D2>To: Multiple recipients of list ORACLE-L</FONT> <BR><FONT SIZE=3D2>Subject: Re: select with Null</FONT> </P> <BR> <BR> <BR> <BR> <P><FONT SIZE=3D2>select d.discount_type</FONT> <BR><FONT SIZE=3D2>&nbsp;&nbsp; from discount d</FONT> <BR><FONT SIZE=3D2>&nbsp;where (NVL(d.company_code,'XX') =3D = 'XX')</FONT> <BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp; and = (NVL(d.operator_code,'YY') =3D 'YY')</FONT> </P> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <P><FONT SIZE=3D2>Raj Gopalan &lt;raj.gopalan_at_netdecisions.co.uk&gt; on = 22/11/2000 12:35:24 PM</FONT> </P> <P><FONT SIZE=3D2>Please respond to ORACLE-L_at_fatcity.com</FONT> <BR><FONT = SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT> <BR><FONT = SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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T> <BR><FONT SIZE=3D2>&nbsp;Subject: select with = Null&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n= bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n= bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = </FONT> <BR><FONT = SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp; </FONT> </P> <BR> <BR> <BR> <BR> <BR> <BR> <P><FONT SIZE=3D2>Hello list,</FONT> </P> <P><FONT SIZE=3D2>I have a query</FONT> </P> <P><FONT SIZE=3D2>select d.discount_type</FONT> <BR><FONT SIZE=3D2>&nbsp;&nbsp; from discount d</FONT> <BR><FONT SIZE=3D2>&nbsp;where (d.company_code =3D 'XX' or</FONT> <BR><FONT = SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp; d.company_code is null)</FONT> <BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp; and (d.operator_code =3D = 'YY' or</FONT> <BR><FONT = SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp; d.operator_code is null)</FONT> </P> <P><FONT SIZE=3D2>Apparently, oracle is not using the index since I am = using IS NULL. But the</FONT> <BR><FONT SIZE=3D2>functional requirement is such that the query need = to consider records even</FONT> <BR><FONT SIZE=3D2>if company_code, Operator_code ,... is null.</FONT> </P> <P><FONT SIZE=3D2>Any thoughts on how do I modify this query so that = the index is being used.</FONT> </P> <P><FONT SIZE=3D2>TIA</FONT> </P> <P><FONT SIZE=3D2>Raj</FONT> <BR><FONT SIZE=3D2>--</FONT> <BR><FONT SIZE=3D2>Please see the official ORACLE-L FAQ: <A = HREF=3D"http://www.orafaq.com" = TARGET=3D"_blank">http://www.orafaq.com</A></FONT> <BR><FONT SIZE=3D2>--</FONT> <BR><FONT SIZE=3D2>Author: Raj Gopalan</FONT> <BR><FONT SIZE=3D2>&nbsp; INET: raj.gopalan_at_netdecisions.co.uk</FONT> </P> <P><FONT SIZE=3D2>Fat City Network Services&nbsp;&nbsp;&nbsp; -- (858) = 538-5051&nbsp; FAX: (858) 538-5051</FONT> <BR><FONT SIZE=3D2>San Diego, = California&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- Public Internet = access / Mailing Lists</FONT> <BR><FONT = SIZE=3D2>---------------------------------------------------------------=
-----</FONT>
<BR><FONT SIZE=3D2>To REMOVE yourself from this mailing list, send an = E-Mail message</FONT> <BR><FONT SIZE=3D2>to: ListGuru_at_fatcity.com (note EXACT spelling of = 'ListGuru') and in</FONT> <BR><FONT SIZE=3D2>the message BODY, include a line containing: UNSUB = ORACLE-L</FONT> <BR><FONT SIZE=3D2>(or the name of mailing list you want to be removed = from).&nbsp; You may</FONT> <BR><FONT SIZE=3D2>also send the HELP command for other information = (like subscribing).</FONT> </P> <BR> <BR> <P><FONT SIZE=3D2>-- </FONT> <BR><FONT SIZE=3D2>Please see the official ORACLE-L FAQ: <A = HREF=3D"http://www.orafaq.com" = TARGET=3D"_blank">http://www.orafaq.com</A></FONT> <BR><FONT SIZE=3D2>-- </FONT> <BR><FONT SIZE=3D2>Author: </FONT> <BR><FONT SIZE=3D2>&nbsp; INET: Marcos.Vera_at_msconsultores.com.pe</FONT> </P> <P><FONT SIZE=3D2>Fat City Network Services&nbsp;&nbsp;&nbsp; -- (858) = 538-5051&nbsp; FAX: (858) 538-5051</FONT> <BR><FONT SIZE=3D2>San Diego, = California&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- Public Internet = access / Mailing Lists</FONT> <BR><FONT = SIZE=3D2>---------------------------------------------------------------=
-----</FONT>
Received on Wed Nov 22 2000 - 13:15:22 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US