Re: R: Query plan on identical tables differs . Why ? - Mailing list pgsql-performance

From Stephan Szabo
Subject Re: R: Query plan on identical tables differs . Why ?
Date
Msg-id 20040513080130.E3465@megazone.bigpanda.com
Whole thread Raw
In response to R: Query plan on identical tables differs . Why ?  ("Fabio Panizzutti" <panizzutti@interlogica.net>)
Responses R: R: Query plan on identical tables differs . Why ?
List pgsql-performance
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.

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: R: Query plan on identical tables differs . Why ?
Next
From: Doug Y
Date:
Subject: Re: Clarification on some settings