pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mike Winter <mike.winter@*nospam**frontlogic.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Question about slow Select when using 'IN'.
Date: Tue, 03 Dec 2002 02:06:16 -0500
Message-ID: <20934.1038899176@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.LNX.4.33L2.0211291623260.18672-100000@frontlogic.com>
References: <Pine.LNX.4.33L2.0211291623260.18672-100000@frontlogic.com>

Mike Winter <mike.winter@*nospam**frontlogic.com> writes:
> My query is of the form:
> SELECT col, count(col) FROM tab WHERE id IN (3,
> 4,7,2, ...) GROUP BY COL ORDER BY count
> for a very large number of rows.

> I have an index on id, so the explain looks like:

> Aggregate  (cost=12.12..12.14 rows=1 width=5)
>   ->  Group  (cost=12.12..12.13 rows=4 width=5)
>         ->  Sort  (cost=12.12..12.12 rows=4 width=5)
>               ->  Index Scan using col_id_idx2, col_id_idx2, col_id_idx2,
> col_id_idx2 on tab  (cost=0.00..12.08 rows=4 width=5)

The planner obviously does not think this is a large table (the cost
estimates correspond to very small numbers of pages).  I wonder
whether you have ever VACUUMed or ANALYZEd the table.

			regards, tom lane



view thread (2+ messages)

Message-ID: <20934.1038899176@sss.pgh.pa.us>
Permalink:  ../20934.1038899176@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20934.1038899176@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, mike.winter@*nospam**frontlogic.com
  Subject: Re: Question about slow Select when using 'IN'.
  In-Reply-To: <20934.1038899176@sss.pgh.pa.us>

* 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