Performing a count(*) on a large table, how to optimize - Mailing list pgsql-general

From Martin Weinberg
Subject Performing a count(*) on a large table, how to optimize
Date
Msg-id 199904151506.LAA08377@osprey.phast.umass.edu
Whole thread Raw
List pgsql-general
PG folks,

I have 5 Gb table (mostly numerical values) and want to be able to
count sources in a range of values, e.g.:

      select count(*) from mytable where x between 1.0 and 2.0;

I have indexed on x and vacuumed.

I notice that these take about 3 minutes on my 450 Xeon Linux box.
A very complicated where clause returning data etc. takes about
the same time.

Is there a way to optimize this type of query?

Thanks!

--M

===========================================================================

Martin Weinberg                      Phone: (413) 545-3821
Dept. of Physics and Astronomy       FAX:   (413) 545-2117/0648
530 Graduate Research Tower
University of Massachusetts
Amherst, MA  01003-4525


pgsql-general by date:

Previous
From: darold
Date:
Subject: The WWW of PostgreSQL
Next
From: Michael J Davis
Date:
Subject: RE: [GENERAL] case problem with MS Access export