Return-Path: <root@fatcity.cts.com>
Received: from ensim.rackshack.net (root@localhost)
 by orafaq.net (8.11.6/8.11.6) with ESMTP id g9GFlrH08073
 for <oracle-l@orafaq.net>; Wed, 16 Oct 2002 10:47:53 -0500
X-ClientAddr: 209.68.248.164
Received: from newsfeed.cts.com (newsfeed.cts.com [209.68.248.164])
 by ensim.rackshack.net (8.11.6/8.11.6) with ESMTP id g9GFloG08061
 for <oracle-l@orafaq.net>; Wed, 16 Oct 2002 10:47:50 -0500
Received: from fatcity.UUCP (uucp@localhost)
 by newsfeed.cts.com (8.9.3/8.9.3) with UUCP id GAA83123;
 Wed, 16 Oct 2002 06:29:27 -0700 (PDT)
Received: by fatcity.com (26-Feb-2001/v1.0g-b72/bab) via UUCP id 004EA57A; Wed, 16 Oct 2002 05:48:42 -0800
Message-ID: <F001.004EA57A.20021016054842@fatcity.com>
Date: Wed, 16 Oct 2002 05:48:42 -0800
To: Multiple recipients of list ORACLE-L <ORACLE-L@fatcity.com>
X-Comment: Oracle RDBMS Community Forum
X-Sender: "Jamadagni, Rajendra" <Rajendra.Jamadagni@espn.com>
Sender: root@fatcity.com
Reply-To: ORACLE-L@fatcity.com
Errors-To: ML-ERRORS@fatcity.com
From: "Jamadagni, Rajendra" <Rajendra.Jamadagni@espn.com>
Subject: RE: Speeding up LIKE '%something%'
Organization: Fat City Network Services, San Diego, California
X-ListServer: v1.0g, build 72; ListGuru (c) 1996-2001 Bruce A. Bergman
Precedence: bulk
Mime-Version: 1.0
Content-Type: multipart/mixed;	boundary="----=_NextPartTM-000-7deb1883-6323-4398-816e-ce621cd7c0cd"
------=_NextPartTM-000-7deb1883-6323-4398-816e-ce621cd7c0cd
Content-Type: multipart/alternative;
 boundary="----_=_NextPart_001_01C27512.23718AE0"
------_=_NextPart_001_01C27512.23718AE0
Content-Type: text/plain;
 charset="iso-8859-1"

Another solution is Intermedia 

Raj
______________________________________________________
Rajendra Jamadagni		MIS, ESPN Inc.
Rajendra dot Jamadagni at ESPN dot com
Any opinion expressed here is personal and doesn't reflect that of ESPN Inc.

QOTD: Any clod can have facts, but having an opinion is an art!


-----Original Message-----
Sent: Wednesday, October 16, 2002 4:29 AM
To: Multiple recipients of list ORACLE-L


"Carle, William T (Bill), ALCAS" wrote:
> 
> Howdy,
> 
>     I have a table that has almost 2 million rows called eventqueueentry.
The layout looks like this:
> 
> Name                                      Null?    Type
>  ----------------------------------------- --------
----------------------------
>  EVENTID                                   NOT NULL NUMBER(10)
>  VER                                       NOT NULL NUMBER(10)
>  QUEUETYPE                                 NOT NULL CHAR(16)
>  PUBLISHER                                 NOT NULL CHAR(16)
>  CREATETIME                                NOT NULL DATE
>  LASTREADTIME                                       DATE
>  REMOVETIME                                         DATE
>  CONTENTS                                  NOT NULL VARCHAR2(4000)
> 
> The users do a query that looks like this:
> 
> SELECT  EventId, QueueType, Publisher, CreateTime, LastReadTime,
RemoveTime,
>   Contents, Ver
> from
>  EventQueueEntry  where QueueType = 'CodeUpdate' AND Contents LIKE
>   '%TrackingEventId=27668677%' ORDER BY EventId
> 
> The queuetype field has only 3 different values. The value in the contents
field is close to being unique (high cardinality) but, as you can see, they
are picking off a value somewhere in the middle of a varchar2(4000) field.
Understandably, their query is slow. Is there anything I can do with an
index to speed this up?
> 
> Bill Carle
> AT&T
> Database Administrator
> 816-995-3922
> wcarle@att.com
> 

I think that if it's 'TrackingEventId' which REALLY interests your users
(as opposed to any random string of characters within CONTENTS) you
should train your users into expressing their query as something similar
to
          to_number(substr(CONTENTS,
                           decode(instr(CONTENTS, 'TrackingEventId='),
0, length(CONTENTS),
                                       instr(CONTENTS,
'TrackingEventId=')+16), 8))
                                          = 27668677

(I do *not* guarantee the number of parentheses :) and I assume that the
number is always 8-digit long - adapt).
This  nice expression would allow you to create a function based index.
In fact, you could then create a view above the table which would
directly include a TRACKINGEVENTID column defined as above, and,
assuming the FBI, your users could query :

SELECT  EventId, QueueType, Publisher, CreateTime, LastReadTime,
RemoveTime,
  Contents, Ver
from
V_EventQueueEntry 
where QueueType = 'CodeUpdate'
AND TrackingEventId=27668677
ORDER BY EventId

Another solution would be to add a column, and extract the information
as it is inserted (trigger) to fill the column - which you would of
course index.

If many different chunks of CONTENTS can be queried, I would consider
Intermedia.

-- 
Regards,

Stephane Faroult
Oriole Software

----- End Forwarded Message -----


Regards,

Stephane Faroult
Oriole
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Stephane Faroul
  INET: sfaroult@oriolecorp.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru@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_01C27512.23718AE0
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.2654.19">
<TITLE>RE: Speeding up LIKE '%something%'</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>Another solution is Intermedia </FONT>
</P>

<P><FONT SIZE=3D2>Raj</FONT>
<BR><FONT =
SIZE=3D2>______________________________________________________</FONT>
<BR><FONT SIZE=3D2>Rajendra Jamadagni&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MIS, ESPN Inc.</FONT>
<BR><FONT SIZE=3D2>Rajendra dot Jamadagni at ESPN dot com</FONT>
<BR><FONT SIZE=3D2>Any opinion expressed here is personal and doesn't =
reflect that of ESPN Inc. </FONT>
<BR><FONT SIZE=3D2>QOTD: Any clod can have facts, but having an opinion =
is an art!</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>-----Original Message-----</FONT>
<BR><FONT SIZE=3D2>From: Stephane Faroult [<A =
HREF=3D"mailto:sfaroult@oriolecorp.com">mailto:sfaroult@oriolecorp.com</=
A>]</FONT>
<BR><FONT SIZE=3D2>Sent: Wednesday, October 16, 2002 4:29 AM</FONT>
<BR><FONT SIZE=3D2>To: Multiple recipients of list ORACLE-L</FONT>
<BR><FONT SIZE=3D2>Subject: Speeding up LIKE '%something%'</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>&quot;Carle, William T (Bill), ALCAS&quot; =
wrote:</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; Howdy,</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; I have a table that has =
almost 2 million rows called eventqueueentry. The layout looks like =
this:</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; =
Name&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;&n=
bsp;&nbsp; Null?&nbsp;&nbsp;&nbsp; Type</FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp; ----------------------------------------- =
-------- ----------------------------</FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp; =
EVENTID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp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T SIZE=3D2>&gt; SELECT&nbsp; EventId, QueueType, Publisher, =
CreateTime, LastReadTime, RemoveTime,</FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp; Contents, Ver</FONT>
<BR><FONT SIZE=3D2>&gt; from</FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp; EventQueueEntry&nbsp; where QueueType =3D =
'CodeUpdate' AND Contents LIKE</FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp; '%TrackingEventId=3D27668677%' =
ORDER BY EventId</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; The queuetype field has only 3 different =
values. The value in the contents field is close to being unique (high =
cardinality) but, as you can see, they are picking off a value =
somewhere in the middle of a varchar2(4000) field. Understandably, =
their query is slow. Is there anything I can do with an index to speed =
this up?</FONT></P>

<P><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; Bill Carle</FONT>
<BR><FONT SIZE=3D2>&gt; AT&amp;T</FONT>
<BR><FONT SIZE=3D2>&gt; Database Administrator</FONT>
<BR><FONT SIZE=3D2>&gt; 816-995-3922</FONT>
<BR><FONT SIZE=3D2>&gt; wcarle@att.com</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
</P>

<P><FONT SIZE=3D2>I think that if it's 'TrackingEventId' which REALLY =
interests your users</FONT>
<BR><FONT SIZE=3D2>(as opposed to any random string of characters =
within CONTENTS) you</FONT>
<BR><FONT SIZE=3D2>should train your users into expressing their query =
as something similar</FONT>
<BR><FONT SIZE=3D2>to</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
to_number(substr(CONTENTS,</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; decode(instr(CONTENTS, =
'TrackingEventId=3D'),</FONT>
<BR><FONT SIZE=3D2>0, length(CONTENTS),</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; instr(CONTENTS,</FONT>
<BR><FONT SIZE=3D2>'TrackingEventId=3D')+16), 8))</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; =3D 27668677</FONT>
</P>

<P><FONT SIZE=3D2>(I do *not* guarantee the number of parentheses :) =
and I assume that the</FONT>
<BR><FONT SIZE=3D2>number is always 8-digit long - adapt).</FONT>
<BR><FONT SIZE=3D2>This&nbsp; nice expression would allow you to create =
a function based index.</FONT>
<BR><FONT SIZE=3D2>In fact, you could then create a view above the =
table which would</FONT>
<BR><FONT SIZE=3D2>directly include a TRACKINGEVENTID column defined as =
above, and,</FONT>
<BR><FONT SIZE=3D2>assuming the FBI, your users could query :</FONT>
</P>

<P><FONT SIZE=3D2>SELECT&nbsp; EventId, QueueType, Publisher, =
CreateTime, LastReadTime,</FONT>
<BR><FONT SIZE=3D2>RemoveTime,</FONT>
<BR><FONT SIZE=3D2>&nbsp; Contents, Ver</FONT>
<BR><FONT SIZE=3D2>from</FONT>
<BR><FONT SIZE=3D2>V_EventQueueEntry </FONT>
<BR><FONT SIZE=3D2>where QueueType =3D 'CodeUpdate'</FONT>
<BR><FONT SIZE=3D2>AND TrackingEventId=3D27668677</FONT>
<BR><FONT SIZE=3D2>ORDER BY EventId</FONT>
</P>

<P><FONT SIZE=3D2>Another solution would be to add a column, and =
extract the information</FONT>
<BR><FONT SIZE=3D2>as it is inserted (trigger) to fill the column - =
which you would of</FONT>
<BR><FONT SIZE=3D2>course index.</FONT>
</P>

<P><FONT SIZE=3D2>If many different chunks of CONTENTS can be queried, =
I would consider</FONT>
<BR><FONT SIZE=3D2>Intermedia.</FONT>
</P>

<P><FONT SIZE=3D2>-- </FONT>
<BR><FONT SIZE=3D2>Regards,</FONT>
</P>

<P><FONT SIZE=3D2>Stephane Faroult</FONT>
<BR><FONT SIZE=3D2>Oriole Software</FONT>
</P>

<P><FONT SIZE=3D2>----- End Forwarded Message -----</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>Regards,</FONT>
</P>

<P><FONT SIZE=3D2>Stephane Faroult</FONT>
<BR><FONT SIZE=3D2>Oriole</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: Stephane Faroul</FONT>
<BR><FONT SIZE=3D2>&nbsp; INET: sfaroult@oriolecorp.com</FONT>
</P>

<P><FONT SIZE=3D2>Fat City Network Services&nbsp;&nbsp;&nbsp; -- =
858-538-5051 <A HREF=3D"http://www.fatcity.com" =
TARGET=3D"_blank">http://www.fatcity.com</A></FONT>
<BR><FONT SIZE=3D2>San Diego, =
California&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- Mailing list =
and web hosting services</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@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>

</BODY>
</HTML>
------_=_NextPart_001_01C27512.23718AE0--


------=_NextPartTM-000-7deb1883-6323-4398-816e-ce621cd7c0cd
Content-Type: text/plain;
 name="ESPN_Disclaimer.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="ESPN_Disclaimer.txt"

*********************************************************************This e-mail message is confidential, intended only for the named recipient(s) above and may contain information that is privileged, attorney work product or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify corporate MIS at (860) 766-2000 and delete this e-mail message from your computer, Thank you.*********************************************************************1

------=_NextPartTM-000-7deb1883-6323-4398-816e-ce621cd7c0cd--

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Jamadagni, Rajendra
  INET: Rajendra.Jamadagni@espn.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru@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).

