Re: Performance issues

From: Vivekanand Joshi <vjoshi(at)zetainteractive(dot)com>
To: vjoshi(at)zetainteractive(dot)com, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Performance issues
Date: 2015-03-17 15:16:03
Message-ID: 6810c9497eee766e15ed238a3bb93203@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

This is the explain for a simple query:

explain Select * from S_V_F_PROMOTION_HISTORY_EMAIL a inner join
S_V_D_CAMPAIGN_HIERARCHY b on a.touchpoint_execution_id =
b.touchpoint_execution_id;

http://explain.depesz.com/s/gse

I am wondering the total cost here is less even then the result is not
coming out.

Regards,
Vivek

-----Original Message-----
From: Vivekanand Joshi [mailto:vjoshi(at)zetainteractive(dot)com]
Sent: Tuesday, March 17, 2015 8:40 PM
To: 'Tomas Vondra'; 'pgsql-performance(at)postgresql(dot)org'
Subject: RE: [PERFORM] Performance issues

The confusion for me here is that :

I am getting results from the view in around 3 seconds
(S_V_D_CAMPAIGN_HIERARCHY) and 25 seconds (S_V_F_PROMOTION_HISTORY_EMAIL)

But when I am using these two views in the query as the joining tables, it
doesn't give any result. As per my understanding, the planner is making new
plan and that is costly instead of using output from the view, which is
actually understandable.

Is there a way, we can do anything about it?

I hope I am making some sense here.

Regards,
Vivek

-----Original Message-----
From: pgsql-performance-owner(at)postgresql(dot)org
[mailto:pgsql-performance-owner(at)postgresql(dot)org] On Behalf Of Tomas Vondra
Sent: Tuesday, March 17, 2015 8:13 PM
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: [PERFORM] Performance issues

On 17.3.2015 15:19, Thomas Kellerer wrote:
> 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.

How do you get the last record (with respect to a timestamp column) using a
DISTINCT ON?

--
Tomas Vondra http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-performance mailing list (pgsql-performance(at)postgresql(dot)org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

Attachment Content-Type Size
Explain.sql text/plain 9.4 KB

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Thomas Kellerer 2015-03-17 15:24:14 Re: Performance issues
Previous Message Vivekanand Joshi 2015-03-17 15:10:03 Re: Performance issues