pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Richard Huxton <dev@archonet.com>
Cc: Dennis Björklund <db@zigo.dhs.org>
Cc: Bradley Tate <btate@objectmastery.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Slow query problem
Date: Fri, 9 Jan 2004 07:38:01 -0800 (PST)
Message-ID: <20040109073400.D69748@megazone.bigpanda.com> (raw)
In-Reply-To: <200401090919.04718.dev@archonet.com>
References: <Pine.LNX.4.44.0401090955490.13405-100000@zigo.dhs.org>
	<200401090919.04718.dev@archonet.com>

On Fri, 9 Jan 2004, Richard Huxton wrote:

> On Friday 09 January 2004 08:57, Dennis Björklund wrote:
> > On Fri, 9 Jan 2004, Richard Huxton wrote:
> > > > > select invheadref, invprodref, sum(units)
> > > > > from invtran
> > > > > group by invheadref, invprodref
> > > >
> > > > For the above query, shouldn't you have one index for both columns
> > > > (invheadref, invprodref). Then it should not need to sort at all to do
> > > > the grouping and it should all be fast.
> > >
> > > Not sure if that would make a difference here, since the whole table is
> > > being read.
> >
> > The goal was to avoid the sorting which should not be needed with that
> > index (I hope). So I still think that it would help in this case.
>
> Sorry - not being clear. I can see how it _might_ help, but will the planner
> take into account the fact that even though:
>   index-cost > seqscan-cost
> that
>   (index-cost + no-sorting) < (seqscan-cost + sort-cost)
> assuming of course, that the costs turn out that way.

AFAICS, yes it does take that effect into account (as best
it can with the estimates).




view thread (11+ messages)

Message-ID: <20040109073400.D69748@megazone.bigpanda.com>
Permalink:  ../20040109073400.D69748@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20040109073400.D69748@megazone.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, dev@archonet.com, db@zigo.dhs.org, btate@objectmastery.com
  Subject: Re: Slow query problem
  In-Reply-To: <20040109073400.D69748@megazone.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox