Re: R: Query plan on identical tables differs . Why ?

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Fabio Panizzutti <panizzutti(at)interlogica(dot)net>
Cc: 'Shridhar Daithankar' <shridhar(at)frodo(dot)hserus(dot)net>, pgsql-performance(at)postgresql(dot)org
Subject: Re: R: Query plan on identical tables differs . Why ?
Date: 2004-05-13 15:16:34
Message-ID: 20040513080130.E3465@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Doug Y 2004-05-13 19:42:20 Re: Clarification on some settings
Previous Message Tom Lane 2004-05-13 15:01:00 Re: R: Query plan on identical tables differs . Why ?