Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YYJZ9-0001sF-1P for pgsql-performance@arkaria.postgresql.org; Wed, 18 Mar 2015 19:23:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YYJZ7-00057w-VL for pgsql-performance@arkaria.postgresql.org; Wed, 18 Mar 2015 19:23:42 +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 1YYJZ7-00057p-04 for pgsql-performance@postgresql.org; Wed, 18 Mar 2015 19:23:41 +0000 Received: from mail-we0-f171.google.com ([74.125.82.171]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YYJZ3-0007q7-Ne for pgsql-performance@postgresql.org; Wed, 18 Mar 2015 19:23:39 +0000 Received: by wegp1 with SMTP id p1so40244366weg.1 for ; Wed, 18 Mar 2015 12:23:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:organization:user-agent :mime-version:to:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=OPhW85RWs2C1CZvpA80QecoqTZhFIrVRL17ozb8iTq0=; b=Lgw0xnDJNV+7RxPE7fnEq5f3rgn/JdtQlAFWCKE4tvB3WpvlZBUsx8dwTP1UqZ+OpW 2GnaqjocDFBlunR4phxX79c1G4Q4hN/mKz0282lzZt+7xgw3+ERlp/ImKd+tZTyEU8hv +SC4Y65pMXN4scVSAWbEFPsTMDMhk6Iv0TMuCvZn/C13O/JX/68TC/IXLssqT32dJ/xL fHFzkx8giIkpeGNROMFUyM7AKcZ/1OJBerf9Fe7LxQHGeu/CrMatCxc53/ZyBsQJpnGt +C4b3KJ59rdDBOFNUNuq6Yif11T3/FiLRM3ftJ8MoXrHxBzT2SOmXOKRKV4Jtnld8YsR p1Bw== X-Gm-Message-State: ALoCoQnT4nWRGpbG53hwj4b6WtdkVmMzaTj4mlK2FRjB9G2eSIx5ruo6u+Rc0Qxfb12RHr55EswcNAcbYwPzlfs6NeTLkbN1Vr1MRWUb6P0uyWIrWqvr8kr4IQBnhNX4ktj/+GYratw25G3OPSpHJELNG4dPQb+SfC2TNm45JCRRojD661Wk0X+bW0VHPAQxqfcNAthrVypC X-Received: by 10.180.90.166 with SMTP id bx6mr9483915wib.65.1426706615682; Wed, 18 Mar 2015 12:23:35 -0700 (PDT) Received: from [192.168.1.163] (ip-78-45-139-138.net.upcbroadband.cz. [78.45.139.138]) by mx.google.com with ESMTPSA id md2sm4399235wic.19.2015.03.18.12.23.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Mar 2015 12:23:34 -0700 (PDT) Message-ID: <5509D0AF.9080305@2ndquadrant.com> Date: Wed, 18 Mar 2015 20:23:27 +0100 From: Tomas Vondra Organization: 2ndQuadrant User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: vjoshi@zetainteractive.com, 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> 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> <9650933705b1a197888f77acbef26728@mail.gmail.com> In-Reply-To: <9650933705b1a197888f77acbef26728@mail.gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) 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 Hi, On 18.3.2015 18:31, Vivekanand Joshi wrote: > 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. The estimates are still miscalculated, but you're forcing the database not to use the nested loop. The problem is the nested loop may be appropriate in some cases (maybe only in a few places of the plan) so this is really corse-grained solution. > But this is not a production-suitable setting. So what do you think > how to get a work around this? (a) Try to identify why the queries are poorly estimated, and rephrase them somehow. This is the best solution, but takes time, expertise and may not be feasible in some cases. (b) Tweak the database structure, possibly introducing intermediate tables, materialized views (or tables maintained by triggers - this might work for the 'latest record' subquery), etc. (c) Try to tweak the cost parameters, to make the nested loops more expensive (and thus less likely to be selected), but in a more gradual way than enable_nestloops=false. regards -- 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