Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id RAA36497 for ; Sun, 30 Jan 2000 17:30:06 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id RAA00500; Sun, 30 Jan 2000 17:29:41 -0500 (EST) To: "Vlad Marchenko" cc: pgsql-sql@postgreSQL.org Subject: Re: [SQL] "Group by" and "index". In-reply-to: <008801bf6b68$4b212f20$2d7a01d4@kuzja> References: <008801bf6b68$4b212f20$2d7a01d4@kuzja> Comments: In-reply-to "Vlad Marchenko" message dated "Sun, 30 Jan 2000 23:23:45 +0200" Date: Sun, 30 Jan 2000 17:29:41 -0500 Message-ID: <497.949271381@sss.pgh.pa.us> From: Tom Lane "Vlad Marchenko" 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 7.0. 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