Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YYIpX-0000Fw-D2 for pgsql-performance@arkaria.postgresql.org; Wed, 18 Mar 2015 18:36:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YYIpW-0003Xw-Rz for pgsql-performance@arkaria.postgresql.org; Wed, 18 Mar 2015 18:36:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YYIpV-0003Xm-TH for pgsql-performance@postgresql.org; Wed, 18 Mar 2015 18:36:34 +0000 Received: from resqmta-ch2-05v.sys.comcast.net ([2001:558:fe21:29:69:252:207:37]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YYIpQ-0007bs-RL for pgsql-performance@postgresql.org; Wed, 18 Mar 2015 18:36:32 +0000 Received: from resomta-ch2-13v.sys.comcast.net ([69.252.207.109]) by resqmta-ch2-05v.sys.comcast.net with comcast id 56bx1q0042N9P4d016cQf3; Wed, 18 Mar 2015 18:36:24 +0000 Received: from jerry.enova.com ([12.30.159.20]) by resomta-ch2-13v.sys.comcast.net with comcast id 56cC1q00N0ShjPw016cEzw; Wed, 18 Mar 2015 18:36:22 +0000 Received: by jerry.enova.com (Postfix, from userid 1001) id 2F5597401EB; Wed, 18 Mar 2015 13:36:12 -0500 (CDT) From: Jerry Sievers To: Cc: Tomas Vondra , pgsql-performance@postgresql.org Subject: Re: Performance issues References: <84a6fe4be04c3ef0a714851977860ac8@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> <55083236.8070900@2ndquadrant.com> <55083D74.4000601@2ndquadrant.com> <9650933705b1a197888f77acbef26728@mail.gmail.com> Date: Wed, 18 Mar 2015 13:36:12 -0500 In-Reply-To: <9650933705b1a197888f77acbef26728@mail.gmail.com> (Vivekanand Joshi's message of "Wed, 18 Mar 2015 23:01:15 +0530") Message-ID: <867fue2lwj.fsf@jerry.enova.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1426703784; bh=FCX9Bxg2XsS+33EUKmnmtMNvZ5jORHQpQlRdky+6vVs=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: MIME-Version:Content-Type; b=B+S1BuY0GXLwQ4zTDw3oLRtTVlGQHwsZTJcj+c0ZEVejbFbLdACQnko1b56yPjz3Y 5rZsvuIiCCArajoTzOk9Th0f0mezgg/13o4C1HMrbQhZ4ChU2lajZTCDIUQLXFNfSn /Qd2C+oYUxen3gfxukih6K8RQ7k0LqB0lGEw0qz7iqaqILFA6sAmRQKEJBsJUThZDb PzOPQuJIUNVXSZyEzdDpwb62SXQbCFqlxtyVNLorndzMKZlYUPJ8nKz8qQrXfWlY/L pKlL8+p4gq2vOl95Zvk3rBhJP9cLFPG+yBzJaTnkU33O2d7ucIEtwr1JgKDgKBsGbW 5QHB9oyOoUsZQ== X-Pg-Spam-Score: -2.5 (--) 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 Vivekanand Joshi writes: > So, here is the first taste of success and which gives me the confidence > that if properly worked out with a good hardware and proper tuning, > PostgreSQL could be a good replacement. > > Out of the 9 reports which needs to be migrated in PostgreSQL, 3 are now > running. > > Report 4 was giving an issue and I will see it tomorrow. > > Just to inform you guys that, the thing that helped most is setting > enable_nestloops to false worked. Plans are now not miscalculated. > > But this is not a production-suitable setting. So what do you think how to > get a work around this? Consider just disabling that setting for 1 or a few odd queries you have for which they are known to plan badly. begin; set local enable_nestloops to false; select ...; commit/abort; I'd say never make that sort of setting DB or cluster-wide. > > > 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 9:00 PM > To: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] Performance issues > > On 17.3.2015 16:24, Thomas Kellerer wrote: >> Tomas Vondra schrieb am 17.03.2015 um 15:43: >>> 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? >> >> You need to use "order by ... desc". See here: >> http://sqlfiddle.com/#!15/d4846/2 > > Nice, thanks! > >> >> Btw: your row_number() usage wouldn't return the "latest" row either. >> It would return the "oldest" row. > > Oh, right. I forgot the DESC in the window. > > > -- > 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 -- Jerry Sievers Postgres DBA/Development Consulting e: postgres.consulting@comcast.net p: 312.241.7800 -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance