X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id CA3CB9FA218 for ; Fri, 26 May 2006 14:07:47 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 75106-01 for ; Fri, 26 May 2006 14:07:42 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 31EB79FA12E for ; Fri, 26 May 2006 14:07:42 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4QH7d4O027138; Fri, 26 May 2006 13:07:39 -0400 (EDT) To: "Merlin Moncure" cc: "Postgresql Performance" Subject: Re: is it possible to make this faster? In-reply-to: References: <15919.1148590347@sss.pgh.pa.us> <16119.1148591497@sss.pgh.pa.us> <25668.1148653358@sss.pgh.pa.us> Comments: In-reply-to "Merlin Moncure" message dated "Fri, 26 May 2006 12:56:44 -0400" Date: Fri, 26 May 2006 13:07:39 -0400 Message-ID: <27137.1148663259@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/495 X-Sequence-Number: 19282 "Merlin Moncure" writes: > did you have a key on a,b,c? Yeah, I did create index t1i on t1 (a,b,c); Do I need to use some other syntax to get it to work? > select count(*) from (select a,b,max(c) group by a,b) q; > blows the high performance case as does putting the query in a view. I noticed that too, while trying to suppress the returning of the results for timing purposes ... still a few bugs in their optimizer obviously. (Curiously, EXPLAIN still claims that the index is being used.) > mysql> select user_id, acc_id, max(sample_date) from usage_samples group by 1,2 > [...] > +---------+--------+------------------+ > 939 rows in set (0.07 sec) > mysql> select user_id, acc_id, max(sample_date) from usage_samples group by 1,2 > [...] > +---------+--------+------------------+--------------+ > 939 rows in set (1.39 sec) I don't understand what you did differently in those two cases? Or was there a DROP INDEX between? regards, tom lane