Re: Optimizing select count query which often takes over 10 seconds

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Optimizing select count query which often takes over 10 seconds
Date: 2013-01-24 16:24:45
Message-ID: CAF-3MvPDDmeQnEC66xu603Bep7bfqGaJJnt+h+4KtBtR9Koi0Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> > It's sorting on disk. That's not going to be fast. Indeed, it's taking
> > nearly all the time the query takes (4.4s for this step out of 4.5s for
> the
> > query).
>
> I've noticed that too, but what
> does "sorting on disk" mean?
>
> I have a lot of RAM (32 GB) ,
> should I increase work_mem even more?
> (it is currenlty 32 MB)
>

You can try increasing the amount of work_mem in your psql session only and
see what amount helps. That way you don't need to permanently increase it
for all your queries.
I'd start with 48 MB and increase in increments of 16 MB (as that's the
size the sort operation claims to require on disk).

--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Steve Clark 2013-01-24 16:47:02 noobie question
Previous Message Noah Misch 2013-01-24 16:19:54 Re: BUG #6510: A simple prompt is displayed using wrong charset