Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / Ingres Topics / December 2003

Tip: Looking for answers? Try searching our database.

upper function and indexes?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gerhard Hofmann - 12 Dec 2003 13:06 GMT
Hi list,

I wonder if indexes will be used when running a query that contains upper
function, example:

select * from mytable where upper(myfield) = 'ABC'

Assuming myfield is indexed: will the index by used or not? We use Ingres
2.5 and 2.6

Regards
Gerhard
Kent Smith - 12 Dec 2003 14:30 GMT
>I wonder if indexes will be used when running a query that contains upper
>function, example:
[quoted text clipped - 3 lines]
>Assuming myfield is indexed: will the index by used or not? We use Ingres
>2.5 and 2.6

Gerhard:

Historically Ingres has NOT used indexes when a function is applied to
the column, but I haven't tried it with 2.6.  You can tell very
quickly by running a QEP on your query in terminal monitor:

set qep;
select * from mytable where upper(myfield) = 'ABC';

The resulting query plan either will or will not use an index.

There are workarounds, of course.  If you always store the data in the
key field as lowercase, then:

select * from mytable where myfield = lower('ABC')

will work (note that the *actual* data presented to the user could be
in myfield2, but the indexed field is always lowercase).  Similarly,
the following might be better for you (if the assumptions it makes are
valid):

select * from mytable
where myfield = 'ABC'
 or myfield = upper('ABC')
 or myfield = lower('ABC')

It wouldn't catch the case where myfield = 'ABc', of course.

Short question.  Long answer.  Hope it is useful.

--Kent

=================================
Kent Smith * IPSO Incorporated
Business * Technology * Solutions
Financial Services and Accounting Systems Consulting

http://www.ipsoinc.com
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.