Re: Performance issue: index not used on GROUP BY...

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: gmb <gmbouwer(at)gmail(dot)com>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Performance issue: index not used on GROUP BY...
Date: 2014-08-28 09:29:46
Message-ID: CABRT9RDQjk6AdAMLE-uft9HT+DwTw0mBA7UN4hXvv_m9kY0Rwg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Thu, Aug 28, 2014 at 11:50 AM, gmb <gmbouwer(at)gmail(dot)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(at)gmail(dot)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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message gmb 2014-08-28 11:29:19 Re: Performance issue: index not used on GROUP BY...
Previous Message Victor Yegorov 2014-08-28 09:28:07 Re: Performance issue: index not used on GROUP BY...