Re: Performance issues

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Performance issues
Date: 2015-03-17 14:19:10
Message-ID: me9d4u$9b5$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Tomas Vondra schrieb am 17.03.2015 um 14:55:
> (2) using window functions, e.g. like this:
>
> SELECT * FROM (
> SELECT *,
> ROW_NUMBER() OVER (PARTITION BY touchpoint_execution_id
> ORDER BY FROM max_creation_dt) AS rn
> FROM s_f_touchpoint_execution_status_history
> ) foo WHERE rn = 1
>
> But estimating this is also rather difficult ...

From my experience rewriting something like the above using DISTINCT ON is usually faster.

e.g.:

select distinct on (touchpoint_execution_id) *
from s_f_touchpoint_execution_status_history
order by touchpoint_execution_id, max_creation_dt;

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tomas Vondra 2015-03-17 14:43:00 Re: Performance issues
Previous Message Tomas Vondra 2015-03-17 13:55:02 Re: Performance issues