The Optimizer?
Posted in 1999
Hi all.
This a very curious situation:
take a table
table_a (
column_1 char(3) not null,
column_2 char(2) not null,
column_3 smallint not null,
column_4 integer,
...
colum_n smallint,
primary key (column_1,column_2,column_3))
Put into this table 5,500,000 records (or more ;-DDDD)
execute the next sql statment:
select *
from table_a
where column_2 = "xx" and
column_2 = "yy"
***** This select is wrong because a column only could have a
value in a record.
Time expended to say "No records found" was 30 minutes with
a lot of reads.
Now replace the column_2 by column_1 in the where clausule
(where column_1 = "xxx" and column_1 = "yyy")
The time expended with this select = 0.00000001 miliseconds
and 3 reads to say "No records found".
Why the optimizer don't optimize the first select?
Why the optimizer optimize the second select (because column_1
it's the first item of a index?) ?
Work environment:
SUN SparcServer 1000e with Solaris 2.4 and 4 Sparc-cpu and
256mb of RAM.
INFORMIX: IDS v 7.27.UC7
Be patient XDD.
---------------------------------------
Isidre PONS ROCA
BASE - Gesti' d'Ingressos Locals
(Diputacio de Tarragona)
Servei de Sistemes de Informacio
Av President Lluis Companys 12-C
43005 - Tarragona
SPAIN
Tel # +34 977 236731
Fax # +34 977 227302
http://www.altanet.org
ipons@dtgna.altanet.org
---------------------------------------