If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > index with functions

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-28-10, 10:36
divak divak is offline
Registered User
 
Join Date: May 2008
Posts: 24
index with functions

hi,
i have a sql where it uses function LENGTH like below
select * from tab1
where
...
and LENGTH(tab1.c1) = 0

i have a index on tab1.c1, but i doubt if it can make anyuse.

So should i have a index with LENGTH on the field or should i modify my sql.
Reply With Quote
  #2 (permalink)  
Old 09-28-10, 11:56
InformixWilli InformixWilli is offline
Registered User
 
Join Date: Sep 2010
Location: Germany, Brunswick
Posts: 52
Its role of the optimizer to use or dont use the index.

In some cases the sequential scan might be faster.

It also depends on the age of your statistics.

Set explain and look if the index is used or not.

Its not possible to create an index on build-in SQL functions, but you can create it on a stored procedure which returns the length.

You can force the optimizer to use the index but thats again this "I dont tell you too much for free"-situation.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On