Re: Question about slow Select when using 'IN'.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mike Winter <mike(dot)winter(at)*nospam**frontlogic(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Question about slow Select when using 'IN'.
Date: 2002-12-03 07:06:16
Message-ID: 20934.1038899176@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Mike Winter <mike(dot)winter(at)*nospam**frontlogic(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Rachel.Vaudron 2002-12-03 08:01:40 EXIST / NOT EXIST
Previous Message Stephan Szabo 2002-12-02 21:27:36 Re: [SQL] CURRENT_TIMSTAMP