Re: Optimizing select count query which often takes over 10 seconds - Mailing list pgsql-general

From Alban Hertroys
Subject Re: Optimizing select count query which often takes over 10 seconds
Date
Msg-id CAF-3MvPDDmeQnEC66xu603Bep7bfqGaJJnt+h+4KtBtR9Koi0Q@mail.gmail.com
Whole thread Raw
In response to Re: Optimizing select count query which often takes over 10 seconds  (Alexander Farber <alexander.farber@gmail.com>)
List 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.

pgsql-general by date:

Previous
From: Albe Laurenz
Date:
Subject: Re: How to identify the source of a deadlock?
Next
From: Steve Clark
Date:
Subject: noobie question