Subject IS OPTIMIZER OPTIMIZING ?
Author albertoperez19
Halo.

I've a database con a table with this schema

CREATE TABLE SESION
(
CODEMP SMALLINT NOT NULL,
C_TRASLADO INTEGER NOT NULL,
C_SESION INTEGER NOT NULL,
F_TRASLADO TIMESTAMP,
H_TRASLADO VARCHAR(5),
IDA_VUELTA CHAR(1),
CONTROL CHAR(1),
CONTROL2 CHAR(1),
NUMERO INTEGER,
AMB_IDA INTEGER,
AMB_VUELTA INTEGER,
CON_IDA INTEGER,
CON_VUELTA INTEGER,
TIEMPO_ESP FLOAT,
FIRMA CHAR(3),
BORRAR CHAR(1),
MARCADA CHAR(1),
KMS INTEGER,
T_IMPORTE FLOAT,
T_KMS INTEGER,
FULTMODIF TIMESTAMP,
HULTMODIF VARCHAR(5),
USUARIO VARCHAR(30),
CONSTRAINT SESION_PRIMARY PRIMARY KEY (CODEMP, C_TRASLADO, C_SESION)
);
and this index.

CREATE INDEX SES_CONT ON SESION(CODEMP, CONTROL, F_TRASLADO,
H_TRASLADO);

this table has about 80.000 records for each "CODEMP"
if I make a query how

select * from sesion where codemp=1 and c_traslado=345

the optimizer uses the index ses_cont and is wrong because if
i use a plan ...

select * from sesion where codemp=1 and c_traslado=345
PLAN ( SESION INDEX ( RDB$PRIMARY17 ))

then the speed to execute is ten times faster.


I think that this is a very simple query ,
the question is .
what is the problem ?

thanks