Re: Large # of rows in query extremely slow, not using

From: Pierre-Frédéric Caillaud <lists(at)boutiquenumerique(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Large # of rows in query extremely slow, not using
Date: 2004-09-14 19:27:55
Message-ID: opseb0ctjmcq72hf@musicbox
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


>> I have a table with ~8 million rows and I am executing a query which
>> should return about ~800,000 rows. The problem is that as soon as I
>> execute the query it absolutely kills my machine and begins swapping
>> for 5 or 6 minutes before it begins returning results. Is postgres
>> trying to load the whole query into memory before returning anything?
>> Also, why would it choose not to use the index? It is properly
>> estimating the # of rows returned. If I set enable_seqscan to off it
>> is just as slow.

1; EXPLAIN ANALYZE.

Note the time it takes. It should not swap, just read data from the disk
(and not kill the machine).

2; Run the query in your software

Note the time it takes. Watch RAM usage. If it's vastly longer and you're
swimming in virtual memory, postgres is not the culprit... rather use a
cursor to fetch a huge resultset bit by bit.

Tell us what you find ?

Regards.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Simon Riggs 2004-09-14 20:38:49 Re: Data Warehouse Reevaluation - MySQL vs Postgres --
Previous Message Vivek Khera 2004-09-14 18:27:46 Re: Data Warehouse Reevaluation - MySQL vs Postgres -- merge tables