Stephane,
> I don't understanf why it makes a seq scan on table mldecs on cases 2
> and 3,
> according that mldecs(ldec_dec_cod) has an index (named
> ldec_dec_cod_mldecs_key). The base is vacuumed and analyzed every
> night. How
> can I use the ldec_dec_cod_mldecs_key index on mldecs ?
First question: Have you actually measured the execution time of the
various queries? There are many cases where a Seq Scan is faster than
an Index Scan. For example, if in Case2, 50% of the entries were
values 'X' of 'Y', then a Seq Scan is the better approach.
Please determine that you actually have a problem with slow execution.Otherwise, the query parser is just doing its
job.
-Josh Berkus