Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YXt8F-0000Pw-42 for pgsql-performance@arkaria.postgresql.org; Tue, 17 Mar 2015 15:10:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YXt8E-00085u-8D for pgsql-performance@arkaria.postgresql.org; Tue, 17 Mar 2015 15:10:10 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YXt8C-000850-U7 for pgsql-performance@postgresql.org; Tue, 17 Mar 2015 15:10:09 +0000 Received: from mail-oi0-x230.google.com ([2607:f8b0:4003:c06::230]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YXt89-00012i-6Y for pgsql-performance@postgresql.org; Tue, 17 Mar 2015 15:10:06 +0000 Received: by oiag65 with SMTP id g65so10746069oia.2 for ; Tue, 17 Mar 2015 08:10:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zetainteractive.com; s=google; h=reply-to:from:references:in-reply-to:mime-version:thread-index:date :message-id:subject:to:content-type; bh=JjDOQ66OZgv0FKx4GMHpdllvPaGeoe7z//jKCEtSAiw=; b=MOxI96iuH31DFA3BxO7QZ2cUFmn7IILEi8ah/R4CTeHgUwe7ZkGvuHADz3w47QnJju 2sRqLPjNdkdVTSLOllW+xlcD0fPpXSbcp15NR7tBZP+xs712qsqCPx2++fcW4yyV5G4Y SeLlwjW/AhnbOJ9VaAQqsgIMqYa3IunVHVDOE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:reply-to:from:references:in-reply-to :mime-version:thread-index:date:message-id:subject:to:content-type; bh=JjDOQ66OZgv0FKx4GMHpdllvPaGeoe7z//jKCEtSAiw=; b=mhwDY83FpsyrGxp0pJDbrawrM1K4nqNZPu2qCtzOTrsdHXJFVgEJ2N3PLIW4kJSFdr vyQdEik6PPRFbwvqq4d3xwwxBZJBxTHKQVk5KiJGKvMs6hE5F4n/acs/ypnlhNgjLEUN Pc8Z5GZlP+87TfAOhcKhPxD66Bkq3eTLLJPn7V/pAKvoYW5IBbnrgWbnZMMSR/l6mc8z 4WfecxyH3gNyOySh1S7wxRbPrFT5c7HWOrPE4qd6az52enDit+bMDgXaTz9UL7wyt9FU XJb2F2s2Unw0vVa8bZOHWf442azgA3u/Ktxgu6lqN0vkpvwh49osXk5xLTt77ajno+Av t0CQ== X-Gm-Message-State: ALoCoQlfVNk4uLYEailltcTNdfzt4L+vesLm5PwG8cEUinmPfuPxzXFW8yFqQ8C8m4Mn+yiBW6II X-Received: by 10.202.50.68 with SMTP id y65mr50586737oiy.91.1426605004169; Tue, 17 Mar 2015 08:10:04 -0700 (PDT) Reply-To: From: Vivekanand Joshi References: <84a6fe4be04c3ef0a714851977860ac8@mail.gmail.com> <160b8780d89add7f23c4eb9c3debb99d@mail.gmail.com> <55034A48.4040409@2ndquadrant.com> <849e75d9463938372dd4c516f5c5d89c@mail.gmail.com> <55037CEA.5050906@2ndquadrant.com> <55073272.20209@BlueTreble.com> <55074424.9050506@2ndquadrant.com> <55076FFB.9090105@BlueTreble.com> c5231342781287ff8cbc9ac1f20ff036@mail.gmail.com <61a7 a27428e588411e8ac1817043205c@mail.gmail.com> <550813CD.7040605@2ndquadrant.com> d6a86358c5e8d7ffe923ff307c3e8c7e@mail.gmail.com <55083236.8070900@2ndquadrant.com> <55083D74.4000601@2ndquadrant.com> In-Reply-To: <55083D74.4000601@2ndquadrant.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 15.0 thread-index: AQGXPdRf3VxuG24kJ8WwflsQcHnAgQHe3/kwAd/iPC4B8TjEOAGXREBQAmaveCgBKBdq4wLp8+fFAS4QZ0UCGdxJjQGaNexKAaH083YA3iIpcwDm/uDBAe8eXBAB/icNowHAYvOEAZPQW7EB4mXi4JyZo7ww Date: Tue, 17 Mar 2015 20:40:03 +0530 Message-ID: <087a57caebe1d71091670f3435d2c1e5@mail.gmail.com> Subject: Re: Performance issues To: Tomas Vondra , pgsql-performance@postgresql.org Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org 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@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Tomas Vondra Sent: Tuesday, March 17, 2015 8:13 PM To: pgsql-performance@postgresql.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@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance