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 C28049FA1F1 for ; Fri, 26 May 2006 13:57:28 -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 72193-06 for ; Fri, 26 May 2006 13:57:19 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.224]) by postgresql.org (Postfix) with ESMTP id C2AFA9FA12E for ; Fri, 26 May 2006 13:57:18 -0300 (ADT) Received: by wr-out-0506.google.com with SMTP id i31so112063wra for ; Fri, 26 May 2006 09:57:17 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=GztsXYNYNmxj0CRh5w9YmVkK8kqes9nBQCGxP/5cqPphLz51DvEf108wuGsq7XygAkw76NfgiE3l4toAjk5vZgvwREfNUfHvKemv8iQTWfKJZ7uyYXx/SbC1MJpo1SQ8MYXMrfSpTmQy9lZGCEBLObBTHwVLWyyuxWUsWuDp4tw= Received: by 10.64.241.8 with SMTP id o8mr560678qbh; Fri, 26 May 2006 09:56:44 -0700 (PDT) Received: by 10.65.137.19 with HTTP; Fri, 26 May 2006 09:56:44 -0700 (PDT) Message-ID: Date: Fri, 26 May 2006 12:56:44 -0400 From: "Merlin Moncure" To: "Tom Lane" Subject: Re: is it possible to make this faster? Cc: "Postgresql Performance" In-Reply-To: <25668.1148653358@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <15919.1148590347@sss.pgh.pa.us> <16119.1148591497@sss.pgh.pa.us> <25668.1148653358@sss.pgh.pa.us> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/494 X-Sequence-Number: 19281 On 5/26/06, Tom Lane wrote: > Well, this bears looking into, because I couldn't get anywhere near 20ms > with mysql. I was using a dual Xeon 2.8GHz machine which ought to be did you have a key on a,b,c? if I include unimportant unkeyed field d the query time drops from 70ms to ~ 1 second. mysql planner is tricky, it's full of special case optimizations... 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. mysql> select version(); +-----------+ | version() | +-----------+ | 5.0.16 | +-----------+ 1 row in set (0.00 sec) mysql> set global query_cache_size =3D 0; Query OK, 0 rows affected (0.00 sec) 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) merlin