pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Dmitry Tkach <dmitry@openratings.com>
Cc: Gregory Wood <gregw@com-stock.com>
Cc: PostgreSQL-General <pgsql-general@postgresql.org>
Subject: Re: Why is it not using an index?
Date: Fri, 15 Mar 2002 12:12:14 -0800 (PST)
Message-ID: <20020315120934.Y54258-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <3C92530D.2050005@openratings.com>


On Fri, 15 Mar 2002, Dmitry Tkach wrote:

> explain select count (x) from a ;
>
> Aggregateš (cost=100175934.05..100175934.05 rows=1 width=2)
> š ->š Seq Scan on aš (cost=100000000.00..100150659.04 rows=10110004 width=2)
>
> Am I missing something here again, or will it just not use an index
> for aggregation?

It won't for something like the above because it needs to test each row
to see if it's currently visible to your transaction (which involves
reading from the table file anyway) which means you end up reading the
entire table plus the index (and paying some costs in random access).
If the index had the transaction information the index would be usable
but there are issues about doing that as well (you might want to check
past messages - especially ones from Tom Lane - on the subject)





view thread (11+ messages)  latest in thread

Message-ID: <20020315120934.Y54258-100000@megazone23.bigpanda.com>
Permalink:  ../20020315120934.Y54258-100000@megazone23.bigpanda.com/
Also on:    postgresql.org/message-id/20020315120934.Y54258-100000@megazone23.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-sql@postgresql.org
  Cc: sszabo@megazone23.bigpanda.com, dmitry@openratings.com, gregw@com-stock.com, pgsql-general@postgresql.org
  Subject: Re: Why is it not using an index?
  In-Reply-To: <20020315120934.Y54258-100000@megazone23.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