From: Merlin Moncure <mmoncure@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Postgresql Performance <pgsql-performance@postgresql.org>
Subject: Re: is it possible to make this faster?
Date: Fri, 26 May 2006 12:56:44 -0400
Message-ID: <b42b73150605260956h30a960efl39d75601d5767747@mail.gmail.com> (raw)
In-Reply-To: <25668.1148653358@sss.pgh.pa.us>
References: <b42b73150605251307id0e7998td4a3693f0d456f88@mail.gmail.com>
<15919.1148590347@sss.pgh.pa.us>
<16119.1148591497@sss.pgh.pa.us>
<b42b73150605252147h218ec25ci183283334731adbd@mail.gmail.com>
<25668.1148653358@sss.pgh.pa.us>
On 5/26/06, Tom Lane <tgl@sss.pgh.pa.us> 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 = 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: mmoncure@gmail.com, tgl@sss.pgh.pa.us
Subject: Re: is it possible to make this faster?
In-Reply-To: <b42b73150605260956h30a960efl39d75601d5767747@mail.gmail.com>
References: <b42b73150605251307id0e7998td4a3693f0d456f88@mail.gmail.com> <15919.1148590347@sss.pgh.pa.us> <16119.1148591497@sss.pgh.pa.us> <b42b73150605252147h218ec25ci183283334731adbd@mail.gmail.com> <25668.1148653358@sss.pgh.pa.us> <b42b73150605260956h30a960efl39d75601d5767747@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox