Re: Informix SQL question
Posted in 1998
Candy,
It doesn't matter what order you specify the columns in you will
always get the same query plan. It also doesn't matter if you have
where a = '1' or where '1' = a.
Regards
David Ashby
______________________________ Reply Separator _________________________________
Subject: Informix SQL question
Author: "Candy McCall" <candym@olcinc.com> at WCA-INET
Date: 03/6/98 10:58 PM
I have a simple question. Suppose you have a table whose primary key is a
composite
key of the columns col1,col2,col3,col4 (primary key is in that order). If you do
a query to
fetch a record by the primary key, does it matter what order you ask for the
columns
in the where clause?
For example, does
SELECT * FROM someTable WHERE col4=? AND col1=? AND
col2=? AND col3=?
get the record as efficiently as the statement
SELECT * FROM someTable WHERE col1=? AND col2=? AND col3=? AND col4=?
I always order the columns in the where clause in the order of the primary key
or the
index I'd like the optimizer to use. I've noticed in the IBM Visual Age for
Java that some
of the code generated to retrieve a row by a primary key may mix up the order.
Thanks!
Candy
--
Candy McCall
ONLINE Computing, Inc.
(candym@olcinc.com)