Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YYHom-0006DW-IS for pgsql-performance@arkaria.postgresql.org; Wed, 18 Mar 2015 17:31:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YYHol-0001k8-GT for pgsql-performance@arkaria.postgresql.org; Wed, 18 Mar 2015 17:31:43 +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 1YYHob-0001Ts-Jf for pgsql-performance@postgresql.org; Wed, 18 Mar 2015 17:31:33 +0000 Received: from mail-oi0-x235.google.com ([2607:f8b0:4003:c06::235]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YYHoM-0006Le-Ak for pgsql-performance@postgresql.org; Wed, 18 Mar 2015 17:31:29 +0000 Received: by oifl3 with SMTP id l3so12522672oif.0 for ; Wed, 18 Mar 2015 10:31:15 -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=fszxQaBgwjPUK5D4GLn6ttAiKnYh9ufo9eB9rmpyjlc=; b=PKhbpNB+qoghkGCUcwLw3DsfEeXAeT+9hki3cHLmoCVIEWRs91CRePJKgvipBcEQhH hFuXcwP1T1gmCzlniUSN6ujZtKAqhcTRSCGEEF6lndmQFwfkPWYukm2MelKcvDPR9C5v 2e9jTzaQLbPvPTNaOu5bGSHcJBVuuIRh420M4= 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=fszxQaBgwjPUK5D4GLn6ttAiKnYh9ufo9eB9rmpyjlc=; b=eRJ4yvFUboIaUZFYEBuW1dkesPj3LA9YAER3JR1F7m6nygU/QdeCMKXg48BdKfuHtk LmB/J3qBmcy3NT6wjoV3GPUBaO7eLX/EsOwLnO3xu7+zsL/xgP0ilRSo8Lc+Zwjd3Fvs vY/fE+4Tm/UCA2083/hGs6Sps/7+8uOZtz8FchwBtXPCLZKpIBdRY/P+uzvSTNpfhOlC 5TEEJizAJkYjRmu7YeqzncmDwr/wNPfsRgeAMWHEh95fRQEiS3GepL9QIuDw6InEe856 edWfclBnRRGC2QSagk04z8XzkCj+T7dn9zQ1Vzs3OuXRLwrYmGJIJahWuqWoPbQBjb8T Dz2A== X-Gm-Message-State: ALoCoQmVwhtDIaUfZybIaHycEpEj0it2ykW89SdhNADMOhVubtcBjnUuqHgYHiL0UwXBzq3kMQ3Y X-Received: by 10.202.106.12 with SMTP id f12mr534030oic.39.1426699875557; Wed, 18 Mar 2015 10:31:15 -0700 (PDT) Reply-To: From: Vivekanand Joshi 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> c5231342781287ff8cbc9ac1f20ff036@mail.gmail.com <61a7 a27428e588411e8ac1817043205c@mail.gmail.com> <550813CD.7040605@2ndqu adrant.com> d6a86358c5e8d7ffe923ff307c3e8c7e@mail.gmail.com <55083236.8070900@2ndquadrant.com> <55083D74.4000601@2ndquadrant.com> <55084890.6000907@2ndqu adrant.com> In-Reply-To: <55084890.6000907@2ndquadrant.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 15.0 thread-index: AQGXPdRf3VxuG24kJ8WwflsQcHnAgQHf4jwuAfE4xDgBl0RAUAJmr3goASgXauMC6fPnxQEuEGdFAhncSY0BmjXsSgGh9PN2AN4iKXMA5v7gwQERqjvMAf4nDaMBwGLzhAGT0FuxAeJl4uACMa83JAIZZZVOnI7nX1A= Date: Wed, 18 Mar 2015 23:01:15 +0530 Message-ID: <9650933705b1a197888f77acbef26728@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 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? 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 -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance