Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TW3cJ-0007q0-FO for pgsql-performance@postgresql.org; Wed, 07 Nov 2012 11:16:19 +0000 Received: from mail-gg0-f174.google.com ([209.85.161.174]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TW3cD-0005tm-4u for pgsql-performance@postgresql.org; Wed, 07 Nov 2012 11:16:19 +0000 Received: by mail-gg0-f174.google.com with SMTP id k5so270535ggd.19 for ; Wed, 07 Nov 2012 03:16:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=PWxlkqJ5wlT3ew9Aio4Sn6+CoFDE1f0dmGVphuRJxhI=; b=eU+aD1GKTRDIQHIlDGF+1lVkcOO0ksGZe9v/qFyxwBRD6s7WUK3Xwmd32/m9jvT0RQ VLOTLb/b21IZYl7srT7rYUDPNAHLgx55bwh7iKz3c6EJO8QTzdd2UxqdOFQBTJI2+SXQ BYUGKs3dztOasBoCT/ZS9AX93XFCulDJlQV3GRAFsM0fNCeE5G6eLT9zMuXETz0FQuCJ HLSvUYHv0h38PvsfX9Oo8Xi5wP6x3R93QERXzejlA0MzcxqwWR+wZZANj9/JAC13UuPJ EaiNf6Vmcw3viFlYVkx+ks6zCjQ4Fw5Lok22NYXCHH2Yz8BPYU5T3zOnmtITUxfd1YMF kbIw== Received: by 10.236.142.139 with SMTP id i11mr4292281yhj.24.1352286972083; Wed, 07 Nov 2012 03:16:12 -0800 (PST) Received: from [187.36.241.94] ([187.36.241.94]) by mx.google.com with ESMTPS id t12sm7458248ane.6.2012.11.07.03.16.10 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 07 Nov 2012 03:16:11 -0800 (PST) Message-ID: <509A42F9.6040403@gmail.com> Date: Wed, 07 Nov 2012 09:16:09 -0200 From: Rodrigo Rosenfeld Rosas User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.10) Gecko/20121027 Icedove/10.0.10 MIME-Version: 1.0 To: Merlin Moncure CC: Tom Lane , pgsql-performance@postgresql.org Subject: Re: Query completed in < 1s in PG 9.1 and ~ 700s in PG 9.2 References: <509944DE.6020400@gmail.com> <5099525B.5070909@gmail.com> <50995D7C.9020108@gmail.com> <17866.1352229874@sss.pgh.pa.us> <50996583.2080703@gmail.com> <18371.1352231105@sss.pgh.pa.us> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) X-Archive-Number: 201211/80 X-Sequence-Number: 48446 Em 06-11-2012 19:11, Merlin Moncure escreveu: > On Tue, Nov 6, 2012 at 1:45 PM, Tom Lane wrote: >> Rodrigo Rosenfeld Rosas writes: >>> Em 06-11-2012 17:24, Tom Lane escreveu: >>>> Can you put together a self-contained test case to duplicate these >>>> results? I'm prepared to believe there's some sort of planner >>>> regression involved here, but we'll never find it without a test case. >>> I'd love to, but I'm afraid I won't have time to do this any time soon. >>> Maybe on Sunday. I'll see if I can get a script to generate the database >>> on Sunday and hope for it to replicate the issue. >>> Would you mind if I coded it using Ruby? (can you run Ruby code in your >>> computer?) I mean, for filling with some sample data. >> No objection. > hm, wouldn't timing the time to generate a raw EXPLAIN (that is, > without ANALYZE) give a rough estimate of planning time? better to > rule it out before OP goes to the trouble... This was a great guess! Congrats, Merlin: PG 9.1 (port 5433): time psql -p 5433 -f slow-explain-only.sql db_name > /dev/null real 0m0.284s user 0m0.068s sys 0m0.012s time psql -p 5432 -f slow-explain-only.sql db_name > /dev/null real 2m10.409s user 0m0.056s sys 0m0.016s time psql -p 5433 -f fast-explain-only.sql db_name > /dev/null real 0m0.264s user 0m0.064s sys 0m0.020s time psql -p 5432 -f fast-explain-only.sql db_name > /dev/null real 12m25.084s user 0m0.052s sys 0m0.020s This is great news because it makes it easier for me to provide a test-case since the results were the same in my test database (which is mostly empty): time psql -p 5432 -f fast-explain-only.sql db_test > /dev/null real 6m0.414s user 0m0.064s sys 0m0.024s I'm in Brazil which is 3 hours behind NY, where my client is. Later when they start their journey I'll ask them if I can send our plain database schema to make it even easier. Otherwise, if they prefer me to create another database schema or to drop the unrelated tables first I'll do that. Maybe they could be afraid of SQL injection attacks although I believe we're currently free of errors of this nature in our applications. Thank you so much for narrowing down the real problem with 9.2. After this regression is fixed in 9.2 I'd like to know if it would be possible to optimize the planner so that slow.sql could perform as well as fast.sql. I believe the unique index on (transaction_id, type_id) helps slow.sql to perform better but if the planner could be smart enough to understand that slow.sql and fast.sql are equivalents I'd prefer to use slow.sql instead of fast.sql as it reads better and it is easier to maintain and write tests for and reduces our database log files. Cheers, Rodrigo.