I had not thought about doing it that way. The table has about 300 million rows, 10,000 of which would contain the value I am searching for which is why I only wanted to see if there was a way to create an index for just 1 value in a column. It will be stored in a separate column. So, as long as I store the value I want and leave the rest NULL, I can accomplish what I am after. Does that mean there is no other way to accomplish this task if I have multiple values?
Thanks,
Rick Stephenson
__ ____ ____ ____ ____ ____ ____
From: Lex de Haan [mailto:lex.de.haan@(protected)] Sent: Tuesday, December 06, 2005 11:59 AM To: Rick Stephenson; oracle-l@(protected) Subject: RE: Function based indexes?
yes, you can -- more or less -- by mapping all other possible outcomes to NULL with a CASE expression. Note however that function-based indexes also store entries for NULL expression outcomes.
By the way, if that value 1 is so special, you might consider to store it in a separate column. Unless tomorrow the special value is suddenly 42 :-)
but why would you bother about a little bit of space? as long as you don't perform full index scans, the performance will not be affected by the index size...
From: oracle-l-bounce@(protected) [mailto:oracle-l-bounce@(protected)] On Behalf Of Rick Stephenson Sent: Tuesday, December 06, 2005 19:45 To: oracle-l@(protected) Subject: Function based indexes?
Is there a way to create an index on a column and only index those where the value meets a certain expression? For example, if I have a numeric column, can I just have the index built for those values that equal 1? I don't query on any other value, so I don't want to consume the space for the other values. I am running EE 9.2.0.3.
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size: 10.0pt;font-family:Arial;color:navy'>I had not thought about doing it that way. The table has about 300 million rows, 10,000 of which would contain the value I am searching for which is why I only wanted to see if there was a way to create an index for just 1 value in a column. It will be stored in a separate column. So, as long as I store the value I want and leave the rest NULL, I can accomplish what I am after. Does that mean there is no other way to accomplish this task if I have multiple values?<o:p></o:p></span></font></p>
<div class=MsoNormal align=center style='text-align:center'><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=2 width="100%" align=center tabindex=-1>
</span></font></div>
<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt; font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> Lex de Haan [mailto:lex.de.haan@(protected)] <br> <b><span style='font-weight:bold'>Sent:</span></b> Tuesday, December 06, 2005 11:59 AM<br> <b><span style='font-weight:bold'>To:</span></b> Rick Stephenson; oracle-l@(protected)<br> <b><span style='font-weight:bold'>Subject:</span></b> RE: Function based indexes?</span></font><o:p></o:p></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: 12.0pt'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";color:blue'>yes, you can -- more or less -- by mapping all other possible outcomes to NULL with a CASE expression. Note however that function-based indexes also store entries for NULL expression outcomes.</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: 12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";color:blue'>By the way, if that value 1 is so special, you might consider to store it in a separate column. Unless tomorrow the special value is suddenly 42 :-)</span></font><o:p> </o:p></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: 12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";color:blue'>but why would you bother about a little bit of space? as long as you don't perform full index scans, the performance will not be affected by the index size...</span></font> <o:p></o:p></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: 12.0pt'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: 12.0pt'> <o:p></o:p></span></font></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: 12.0pt'><o:p> </o:p></span></font></p>
<div class=MsoNormal align=center style='text-align:center'><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=2 width="100%" align=center tabIndex=-1>
</span></font></div>
<p class=MsoNormal style='margin-bottom:12.0pt'><b><font size=2 face=Tahoma> <span style='font-size:10.0pt;font-family:Tahoma;font-weight:bold'>From:</span></font ></b><font size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> oracle-l-bounce@(protected) [mailto:oracle-l-bounce@(protected)] <b><span style='font-weight:bold'>On Behalf Of </span></b>Rick Stephenson<br> <b><span style='font-weight:bold'>Sent:</span></b> Tuesday, December 06, 2005 19:45<br> <b><span style='font-weight:bold'>To:</span></b> oracle-l@(protected)<br> <b><span style='font-weight:bold'>Subject:</span></b> Function based indexes?< /span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>Is there a way to create an index on a column and only index those where the value meets a certain expression? For example, if I have a numeric column, can I just have the index built for those values that equal 1? I don’t query on any other value, so I don’t want to consume the space for the other values. I am running EE 9.2.0.3.<o:p></o :p></span></font></p>