Re: Performance issue: index not used on GROUP BY... - Mailing list pgsql-performance

From Marti Raudsepp
Subject Re: Performance issue: index not used on GROUP BY...
Date
Msg-id CABRT9RDQjk6AdAMLE-uft9HT+DwTw0mBA7UN4hXvv_m9kY0Rwg@mail.gmail.com
Whole thread Raw
In response to Re: Performance issue: index not used on GROUP BY...  (gmb <gmbouwer@gmail.com>)
List pgsql-performance
On Thu, Aug 28, 2014 at 11:50 AM, gmb <gmbouwer@gmail.com> wrote:
> Can somebody please confirm whether aggregate functions such as GROUP BY
> should use indexes ?

Yes, if the planner deems it faster than other approaches. It can make
wrong choices for many reasons, but usually when your planner tunables
like random_page_cost, effective_cache_size aren't set appropriately.

There's some advice here:
https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server

Just for the purpose of testing, you could try "set enable_sort=false"
in your session and see if that makes it faster.

On Thu, Aug 28, 2014 at 12:08 PM, gmb <gmbouwer@gmail.com> wrote:
>         Sort Key: co_id, client_id, doc_no,

Something went missing from this line...

>         Sort Method: external merge  Disk: 80304kB

Depends on your hardware and workloads, but more work_mem may also
improve queries to avoid sorts and hashes needing to use disk. But
beware, setting it too high may result in your server running out of
memory.

Regards,
Marti


pgsql-performance by date:

Previous
From: Victor Yegorov
Date:
Subject: Re: Performance issue: index not used on GROUP BY...
Next
From: gmb
Date:
Subject: Re: Performance issue: index not used on GROUP BY...