Which index is fastest
Posted in 1999
Topics: General Discussion
Hi,
having the table:
create table orders
(company smallint,
customer char(6),
num_order integer,
...
)
Which index is fastest in order to find ONE row ?
create index orders_1 on order (company, customer, num_order); or
create index orders_1 on order (num_order, customer, company);
and doing:
select * from orders
where company = 1 and customer = "0001" and num_order = 1000
for few companys, and lots of customer and orders ...
Thanks,
Thanks a lot,
Manel Falcó
SEMIC, S.A.
Lleida-Catalonia-Spain-Europe
-----------------------------------------------------
Informix version: Informix SE 5.07 / RDS 4.x & 4J's
Operating system: Unix SCO V 5.04
-----------------------------------------------------
The easiest way for YOU to find out is running the query after using the SET
EXPLAIN ON command
SET EXPLAIN ON;query ...
This will generate a sqexplain.out file that will contain information you
can use to make your own decision.
Don't forget that running Update Statistics should be performed after adding
the index you are trying out.
Take care.
Clifton
Manel Falc' wrote in message <36c41fc1.15758373@news.bcn.ttd.net>...
>Hi,
>
>having the table:
>
> create table orders
> (company smallint,
> customer char(6),
> num_order integer,
> ...
> )>
>Which index is fastest in order to find ONE row ?
>
> create index orders_1 on order (company, customer, num_order);> or
> create index orders_1 on order (num_order, customer, company);>
>and doing:
> select * from orders
> where company = 1 and customer = "0001" and num_order = 1000>
>for few companys, and lots of customer and orders ...
>
>Thanks,
>
>Thanks a lot,
>
>Manel Falc'
>SEMIC, S.A.
>Lleida-Catalonia-Spain-Europe
>-----------------------------------------------------
>Informix version: Informix SE 5.07 / RDS 4.x & 4J's
>Operating system: Unix SCO V 5.04
>-----------------------------------------------------