From: | Rod Taylor <rbt(at)rbt(dot)ca> |
---|---|
To: | Max Baker <max(at)warped(dot)org> |
Cc: | PostgreSQL Performance Mailing List <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: speeding up COUNT and DISTINCT queries |
Date: | 2003-03-12 22:52:19 |
Message-ID: | 1047509538.57729.4.camel@jester |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Wed, 2003-03-12 at 17:38, Max Baker wrote:
> I'm looking for a general method to
> speed up DISTINCT and COUNT queries.
>
>
> mydatabase=> EXPLAIN ANALYZE select distinct(mac) from node;
> NOTICE: QUERY PLAN:
>
> Unique (cost=110425.67..110514.57 rows=3556 width=6) (actual
> time=45289.78..45598.62 rows=25334 loops=1)
> -> Sort (cost=110425.67..110425.67 rows=35561 width=6) (actual
> time=45289.77..45411.53 rows=34597 loops=1)
> -> Seq Scan on node (cost=0.00..107737.61 rows=35561
> width=6) (actual time=6.73..44383.57 rows=34597 loops=1)
>
> Total runtime: 45673.19 msec
> ouch.
>
> I run VACCUUM ANALYZE once a day.
Thats not going to do anything for that query, as there only is one
possible plan at the moment :)
I don't think you can do much about that query, other than buy a faster
harddisk or more ram. Nearly all the time seems to be used pulling the
data off the disk (in the Seq Scan).
--
Rod Taylor <rbt(at)rbt(dot)ca>
PGP Key: http://www.rbt.ca/rbtpub.asc
From | Date | Subject | |
---|---|---|---|
Next Message | Chad Thompson | 2003-03-12 22:55:09 | Re: speeding up COUNT and DISTINCT queries |
Previous Message | Max Baker | 2003-03-12 22:38:11 | speeding up COUNT and DISTINCT queries |