speeding up COUNT and DISTINCT queries - Mailing list pgsql-performance

From Max Baker
Subject speeding up COUNT and DISTINCT queries
Date
Msg-id 20030312223811.GM30411@warped.org
Whole thread Raw
Responses Re: speeding up COUNT and DISTINCT queries  (Rod Taylor <rbt@rbt.ca>)
Re: speeding up COUNT and DISTINCT queries  (Manfred Koizar <mkoi-pg@aon.at>)
List pgsql-performance
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.

Thanks,
max

pgsql-performance by date:

Previous
From: Rod Taylor
Date:
Subject: Re: Postgresql performance
Next
From: Rod Taylor
Date:
Subject: Re: speeding up COUNT and DISTINCT queries