On Thu, 13 May 2004, Fabio Panizzutti wrote:
> I don't understand why the planner chose a different query plan on
> identical tables with same indexes .
Because it's more than table structure that affects the choice made by the
planner. In addition the statistics about the values that are there as
well as the estimated size of the table have effects. One way to see is
to see what it thinks is best is to remove the indexes it is using and see
what plan it gives then, how long it takes and the estimated costs for
those plans.
In other suggestions, I think having a (tag_id, data_tag) index rather
than (data_tag, tag_id) may be a win for queries like this. Also, unless
you're doing many select queries by only the first field of the composite
index and you're not doing very many insert/update/deletes, you may want
to drop the other index on just that field.