From: | Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> |
---|---|
To: | Yang Zhang <yanghatespam(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Sorting performance vs. MySQL |
Date: | 2010-02-23 06:48:25 |
Message-ID: | dcc563d11002222248p3cfcd35ag52fc25f376649c09@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Feb 22, 2010 at 10:51 PM, Yang Zhang <yanghatespam(at)gmail(dot)com> wrote:
> nnnnnOn Mon, Feb 22, 2010 at 3:45 PM, Scott Marlowe
> <scott(dot)marlowe(at)gmail(dot)com> wrote:
>>
>> What do things like vmstat 10 say while the query is running on each
>> db? First time, second time, things like that.
>
> Awesome -- this actually led me to discover the problem.
>
> vmstat showed no swapping-out for a while, and then suddenly it
> started spilling a lot. Checking psql's memory stats showed that it
> was huge -- apparently, it's trying to store its full result set in
> memory. As soon as I added a LIMIT 10000, everything worked
> beautifully and finished in 4m (I verified that the planner was still
> issuing a Sort).
>
> I'm relieved that Postgresql itself does not, in fact, suck, but
> slightly disappointed in the behavior of psql. I suppose it needs to
> buffer everything in memory to properly format its tabular output,
> among other possible reasons I could imagine.
It's best when working with big sets to do so with a cursor and fetch
a few thousand rows at a time. It's how we handle really big sets at
work and it works like a charm in keeping the client from bogging down
with a huge memory footprint.
From | Date | Subject | |
---|---|---|---|
Next Message | Alex Hunsaker | 2010-02-23 06:49:13 | Re: Sorting performance vs. MySQL |
Previous Message | Net Tree Inc. | 2010-02-23 06:39:44 | Re: how do I do dump and restore without bugging with constraint? |