Re: Anything I can do to speed up this query?

From: Alexander Staubo <alex(at)purefiction(dot)net>
To: Wei Weng <wweng(at)kencast(dot)com>
Cc: PostgreSQL-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Anything I can do to speed up this query?
Date: 2006-12-05 21:15:39
Message-ID: 9498A3B4-FB6B-4EE8-BA2E-CAC95E82E258@purefiction.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Dec 5, 2006, at 21:56 , Wei Weng wrote:

> I have a table that has roughly 200,000 entries and many columns.
>
> The query is very simple:
>
> SELECT Field1, Field2, Field3... FieldN FROM TargetTable;

This is the very definition of a sequential scan: you're reading
200,000 rows from that table, and the performance of doing this is
constrained by the amount of time PostgreSQL can read the data from
(at worst) disk or (at best) the disk cache. It's bound to be slow on
any database system.

> Test=> show shared_buffers ;
> shared_buffers
> ----------------
> 60800
> (1 row)

That's 475MB. How large is your table? You can find out with this query:

select relpages * 8192 from pg_class where relname ilike
'TargetTable';

Note that unlike the 8.x series, 7.4 apparently doesn't use
shared_buffers that much for caching tuples across queries. In other
words, a large shared_buffers setting might not have much of an effect.

Also: How much memory is left available to the OS cache?

Alexander.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moran 2006-12-05 21:29:42 Re: Online index builds (was: [ANNOUNCE] PostgreSQL 8.2
Previous Message Joshua D. Drake 2006-12-05 21:13:42 Re: Online index builds (was: [ANNOUNCE] PostgreSQL 8.2