Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YWCGC-0006TL-5f for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Mar 2015 23:11:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YWCGB-0003sA-2g for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Mar 2015 23:11:23 +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 1YWCG9-0003s1-11 for pgsql-bugs@postgresql.org; Thu, 12 Mar 2015 23:11:21 +0000 Received: from mail-wg0-f41.google.com ([74.125.82.41]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YWCG5-0004Ny-GI for pgsql-bugs@postgresql.org; Thu, 12 Mar 2015 23:11:19 +0000 Received: by wghk14 with SMTP id k14so19674013wgh.3 for ; Thu, 12 Mar 2015 16:11:15 -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=34o8VTrCo6R8+RmTxKkjhitaiZsk36umtJmoj3HFWoU=; b=KcHonkLEVa1WIpaD/YLavINYUNhvIfGEU6fozLMvHj9zSXKhCZpd0TgaDeD/A/7P2f N++A/2KXO09Ge7vPi+/S5LqA8coljdUtQH3rxgmFuzE0SDLRRD1gUjpAF3eHN1gpUPk5 PT9aMooU3j0FVIERRClE9vwwlxVDlK2i2LEWH2eEYD63WIJ6Qrv8ESjAknPBJM2LPN65 RXuG8c5+GPuXF5MK2Ohi4HrHIIrGH1Or7JE893VdmNxdDNFJZpyqwutDEvpCTZ2LcItU vzgfWcmZ9QnWnPGTvj03rYpEnCMDe1EWN/0zSGU2zZtPDFVt84vI8HRLdsg6VRwuzXlt HBWg== X-Gm-Message-State: ALoCoQlvLGvO3chYuEzh+9X2iEkEPkvQH67hwWjeK+DtWeLsaK4yg9G39TDFYUVTzy1V2sF4SW2PQUO9VIkyVHuXCEZQ7v3ZmO3nZA+8KSWnwyBHmjUJWaJHSfXh1Dq4oH6w5Is71Sizmpm9JG9nlB1YWBmKMosz3jKU5zHq/V/1VDEsHEFkR0OwThewlDgS7tXeQcT5rOkd X-Received: by 10.194.187.46 with SMTP id fp14mr3945988wjc.86.1426201875023; Thu, 12 Mar 2015 16:11:15 -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 k6sm368337wia.6.2015.03.12.16.11.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Mar 2015 16:11:13 -0700 (PDT) Message-ID: <55021CF6.7010400@2ndquadrant.com> Date: Fri, 13 Mar 2015 00:10:46 +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: pgsql-bugs@postgresql.org Subject: Re: BUG #12859: views much slower in 9.4.1 than 8.4.7 References: <20150312205957.2516.65314@wrigleys.postgresql.org> In-Reply-To: <20150312205957.2516.65314@wrigleys.postgresql.org> 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-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Hi, On 12.3.2015 21:59, lcarson@sdsc.edu wrote: > The following bug has been logged on the website: > > Bug reference: 12859 > Logged by: lcarson > Email address: lcarson@sdsc.edu > PostgreSQL version: 9.4.1 > Operating system: redhat 6 > Description: > > We have views that are running anywhere from 20x slower to failing to > complete in 9.4.1 whereas in 8.4.7 they produced results in seconds > or tensof seconds on the same platform. > > After upgrading from 8.4 to 9.3, I ran ANALYZE on the entire db and > it DID improve performance for some, but not all, of the views in > question. > > Here is an explain plan of one of the slow views in 9.4: > http://explain.depesz.com/s/36n > > While acknowledging that nested loops and sequential scans account > for 85% of the execution time, why would this run in seconds in 8.4 > and minutes in 9.4? Is it because of changes to the planner? You have not provided explain plans from 8.4, and I'd bet it was using a different plan on that version. The problem here are under-estimates, pushing the planner to use nested loops - it simply believes there will be very few loops, but in reality there are many more. The differences are several orders of magnitude, starting with Nested Loop (cost=0.29..79,861.74 rows=2 width=141) (actual time=0.079..473.530 rows=23,832 loops=1) for the inner-most nested loop (12000x more) and snowballing up to this Nested Loop (cost=71,484.01..71,501.60 rows=1 width=28) (actual time=379,042.815..383,820.341 rows=263,371 loops=1) I wonder why the estimates are so much worse, though. -- Tomas Vondra http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs