Re: Window functions, partitioning, and sorting performance

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: Eli Naeher <enaeher(at)gmail(dot)com>
Cc: pgsql-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Window functions, partitioning, and sorting performance
Date: 2014-08-21 17:14:31
Message-ID: CABRT9RDUDtH+=Mk7ytML+Ws8Pp0VscgdhzvZphXUr=PrSXVihQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Thu, Aug 21, 2014 at 7:19 PM, Eli Naeher <enaeher(at)gmail(dot)com> wrote:
> However, when I try to do a
> test self-join using it, Postgres does two seq scans across the whole table,
> even though I have indexes on both id and previous_stop_event:
> http://explain.depesz.com/s/ctck. Any idea why those indexes are not being
> used?

Because the planner thinks seq scan+hash join is going to be faster
than incurring the overhead of index scans for other kinds of plans.

You can try out alternative plan types by running 'set
enable_hashjoin=off' in your session. If it does turn out to be
faster, then it usually means you haven't set planner tunables right
(random_page_cost, effective_cache_size and possibly cpu_tuple_cost).

Regards,
Marti

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Graeme B. Bell 2014-08-21 20:03:13 Re: Turn off Hyperthreading! WAS: 60 core performance with 9.3
Previous Message Eli Naeher 2014-08-21 16:21:03 Re: Window functions, partitioning, and sorting performance