dbTalk Databases Forums  

Is function index the best solution?

comp.databases.oracle.server comp.databases.oracle.server


Discuss Is function index the best solution? in the comp.databases.oracle.server forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Robert Nicholson
 
Posts: n/a

Default Is function index the best solution? - 09-26-2010 , 08:46 PM






We have a query that uses the following style of query

WHERE TYPE in ('A','B') AND (ACCOUNT LIKE '%9999' OR ACCOUNT LIKE
'%1111) AND TIME >= :1 AND TIME <= :2 order by TIME

....

right now this query tablescans

Is a function index using ACCOUNT the only way to avoid a tablescan?

There are indexes on account and the time columns but this query still
performs a full tablescan.

Execution Statistics

Total Per Execution Per Row

executions 163 1 n/a
Elapsed Time (sec) 12,932.65 79.34 n/a
CPU Time (sec) 4,615.64 28.32 n/a
Buffer Gets 198,614,100 1,218,491.41 n/a
Disk Reads 63,106,576 387,156.91 n/a
Direct Writes 0 0.00 n/a
Rows 0 0.00 n/a
Fetches 162 0.99 n/a

Reply With Quote
  #2  
Old   
ddf
 
Posts: n/a

Default Re: Is function index the best solution? - 09-26-2010 , 10:39 PM






On Sep 26, 9:46*pm, Robert Nicholson <robert.nichol... (AT) gmail (DOT) com>
wrote:
Quote:
We have a query that uses the following style of query

WHERE TYPE in ('A','B') AND (ACCOUNT LIKE '%9999' OR ACCOUNT LIKE
'%1111) AND TIME >= :1 AND TIME <= :2 order by TIME

...

right now this query tablescans

Is a function index using ACCOUNT the only way to avoid a tablescan?

There are indexes on account and the time columns but this query still
performs a full tablescan.

Execution Statistics

* * * * Total * Per Execution * Per Row

executions * * *163 * * 1 * * * n/a
Elapsed Time (sec) * * *12,932.65 * * * 79.34 * n/a
CPU Time (sec) *4,615.64 * * * *28.32 * n/a
Buffer Gets * * 198,614,100 * * 1,218,491.41 * *n/a
Disk Reads * * *63,106,576 * * *387,156.91 * * *n/a
Direct Writes * 0 * * * 0.00 * *n/a
Rows * *0 * * * 0.00 * *n/a
Fetches 162 * * 0.99 * *n/a
I see no function in use against the ACCOUNT column; I do see leading
wildcards in the WHERE clause which guarantees you a full tablescan.


David Fitzjarrell

Reply With Quote
  #3  
Old   
Robert Nicholson
 
Posts: n/a

Default Re: Is function index the best solution? - 09-26-2010 , 11:42 PM



On Sep 26, 10:39*pm, ddf <orat... (AT) msn (DOT) com> wrote:
Quote:
On Sep 26, 9:46*pm, Robert Nicholson <robert.nichol... (AT) gmail (DOT) com
wrote:





We have a query that uses the following style of query

WHERE TYPE in ('A','B') AND (ACCOUNT LIKE '%9999' OR ACCOUNT LIKE
'%1111) AND TIME >= :1 AND TIME <= :2 order by TIME

...

right now this query tablescans

Is a function index using ACCOUNT the only way to avoid a tablescan?

There are indexes on account and the time columns but this query still
performs a full tablescan.

Execution Statistics

* * * * Total * Per Execution * Per Row

Yes that is correct. The question is whether a function index in
account
ie. wrapping the likes in a case block is an appropriate remedy for
this
type of problem?

Quote:
executions * * *163 * * 1 * * * n/a
Elapsed Time (sec) * * *12,932.65 * * * 79.34 * n/a
CPU Time (sec) *4,615.64 * * * *28.32 * n/a
Buffer Gets * * 198,614,100 * * 1,218,491.41 * *n/a
Disk Reads * * *63,106,576 * * *387,156.91 * * *n/a
Direct Writes * 0 * * * 0.00 * *n/a
Rows * *0 * * * 0.00 * *n/a
Fetches 162 * * 0.99 * *n/a

I see no function in use against the ACCOUNT column; I do see leading
wildcards in the WHERE clause which guarantees you a full tablescan.

David Fitzjarrell

Reply With Quote
  #4  
Old   
Michel Cadot
 
Posts: n/a

Default Re: Is function index the best solution? - 09-27-2010 , 12:40 AM



"Robert Nicholson" <robert.nicholson (AT) gmail (DOT) com> a écrit dans le message de news:
9804a980-d9e9-4596-b012-000159e1a7b6...oglegroups.com...
Quote:
We have a query that uses the following style of query

WHERE TYPE in ('A','B') AND (ACCOUNT LIKE '%9999' OR ACCOUNT LIKE
'%1111) AND TIME >= :1 AND TIME <= :2 order by TIME

...

right now this query tablescans

Is a function index using ACCOUNT the only way to avoid a tablescan?

There are indexes on account and the time columns but this query still
performs a full tablescan.

Execution Statistics

Total Per Execution Per Row

executions 163 1 n/a
Elapsed Time (sec) 12,932.65 79.34 n/a
CPU Time (sec) 4,615.64 28.32 n/a
Buffer Gets 198,614,100 1,218,491.41 n/a
Disk Reads 63,106,576 387,156.91 n/a
Direct Writes 0 0.00 n/a
Rows 0 0.00 n/a
Fetches 162 0.99 n/a
Use an FBI on REVERSE(ACCOUNT)
and condition on REVERSE(ACCOUNT) LIKE '1111%'.

SQL> select REVERSE('MICHEL') from dual;
REVERS
------
LEHCIM

Regards
Michel

Reply With Quote
  #5  
Old   
Steve Howard
 
Posts: n/a

Default Re: Is function index the best solution? - 09-27-2010 , 02:21 PM



On Sep 26, 9:46*pm, Robert Nicholson <robert.nichol... (AT) gmail (DOT) com>
wrote:
Quote:
We have a query that uses the following style of query

WHERE TYPE in ('A','B') AND (ACCOUNT LIKE '%9999' OR ACCOUNT LIKE
'%1111) AND TIME >= :1 AND TIME <= :2 order by TIME

...

right now this query tablescans

Is a function index using ACCOUNT the only way to avoid a tablescan?

There are indexes on account and the time columns but this query still
performs a full tablescan.

Execution Statistics

* * * * Total * Per Execution * Per Row

executions * * *163 * * 1 * * * n/a
Elapsed Time (sec) * * *12,932.65 * * * 79.34 * n/a
CPU Time (sec) *4,615.64 * * * *28.32 * n/a
Buffer Gets * * 198,614,100 * * 1,218,491.41 * *n/a
Disk Reads * * *63,106,576 * * *387,156.91 * * *n/a
Direct Writes * 0 * * * 0.00 * *n/a
Rows * *0 * * * 0.00 * *n/a
Fetches 162 * * 0.99 * *n/a

Hi Robert,

I honestly have no clue. How selective is the (assumable) date range
of AND TIME >= :1 AND TIME <= :2? How many accounts will end with
9999 or 1111 as a percentage of the table? If that is a large
percentage, an index may not matter.

Post some data and table sizes and the feedback will probably be
measurably better.

Thanks,

Steve

Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.