Skip site navigation (1) Skip section navigation (2)

Re: [SQL] "Group by" and "index".

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Vlad Marchenko" <vlad(at)infonet(dot)com(dot)ua>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] "Group by" and "index".
Date: 2000-01-30 22:29:41
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
"Vlad Marchenko" <vlad(at)infonet(dot)com(dot)ua> writes:
>> explain select field1 from test group by field1;
> It don't use this index :-(.

That's a deficiency of the 6.5 planner; it won't consider an indexscan
unless there's a WHERE clause that matches the index.  This is fixed for

However, the 6.5 planner is not necessarily doing the wrong thing here!
Replacing the explicit sort with an index scan could easily produce a
slower query.  Index scans are good for pulling out a few items,
but when you are going to end up fetching the whole table, they are
pretty slow because of the nonsequential disk accesses they cause.

			regards, tom lane

In response to

pgsql-sql by date

Next:From: Jan WieckDate: 2000-01-31 09:49:52
Subject: Re: [HACKERS] Help with pl/pgsql, triggers, and foreign keys
Previous:From: Vlad MarchenkoDate: 2000-01-30 21:23:45
Subject: "Group by" and "index".

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group