Re: is it possible to make this faster? - Mailing list pgsql-performance

From Merlin Moncure
Subject Re: is it possible to make this faster?
Date
Msg-id [email protected]
Whole thread Raw
In response to Re: is it possible to make this faster?  (Tom Lane <[email protected]>)
Responses Re: is it possible to make this faster?
List pgsql-performance
On 5/26/06, Tom Lane <[email protected]> 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

pgsql-performance by date:

Previous
From: Ragnar
Date:
Subject: Re: column totals
Next
From: Tom Lane
Date:
Subject: Re: is it possible to make this faster?