Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VGwMn-00068q-Ve for pgsql-performance@arkaria.postgresql.org; Tue, 03 Sep 2013 19:34:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VGwMn-0005iO-G0 for pgsql-performance@arkaria.postgresql.org; Tue, 03 Sep 2013 19:34:21 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VGwMm-0005iE-Ja for pgsql-performance@postgresql.org; Tue, 03 Sep 2013 19:34:20 +0000 Received: from 2605ds1-ynoe.3.fullrate.dk ([90.185.142.83] helo=shrek.krogh.cc) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VGwMi-0007Ub-JL for pgsql-performance@postgresql.org; Tue, 03 Sep 2013 19:34:19 +0000 Received: from localhost (localhost [127.0.0.1]) by shrek.krogh.cc (Postfix) with ESMTP id C1890346C73; Tue, 3 Sep 2013 21:54:41 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at shrek.krogh.cc Received: from shrek.krogh.cc ([127.0.0.1]) by localhost (shrek.krogh.cc [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rgRNQgCeiAIC; Tue, 3 Sep 2013 21:54:39 +0200 (CEST) Received: from [90.185.142.91] (2605ds1-ynoe.4.fullrate.dk [90.185.142.91]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jesper@krogh.cc) by shrek.krogh.cc (Postfix) with ESMTPSA id D6FB4346C72; Tue, 3 Sep 2013 21:54:38 +0200 (CEST) Message-ID: <522639B2.4010309@krogh.cc> Date: Tue, 03 Sep 2013 21:34:10 +0200 From: Jesper Krogh User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130330 Thunderbird/17.0.5 MIME-Version: 1.0 To: Craig Ringer CC: "pgsql-performance@postgresql.org" Subject: Re: Slow query-plan generation (fast query) PG 9.2 References: <522593FC.3010302@2ndquadrant.com> In-Reply-To: <522593FC.3010302@2ndquadrant.com> Content-Type: multipart/alternative; boundary="------------080501010904040205050005" X-Pg-Spam-Score: -0.0 (/) 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 This is a multi-part message in MIME format. --------------080501010904040205050005 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 03/09/13 09:47, Craig Ringer wrote: > On 09/03/2013 03:46 PM, jesper@krogh.cc wrote: >> Hi. >> >> I have a strange situation where generating the query plan takes 6s+ and >> executing it takes very little time. > How do you determine that it's planning time at fault here? Not that I'm sure, but the timing I send were only for "explain" not "explain analyze". The database is constantly updating and at the moment i cannot reproduce it any more. But at the time I picked the numbers it were very reproducible.. (tried 10+ times over 15 minutes). Please take separate timing for: PREPARE testq AS select table.id from db.table left join db.tablepro on db.id = tablepro.table_id where table.fts @@ to_tsquery('english','q12345') ; and then: EXPLAIN ANALYZE EXECUTE testq; I'll try to do that if i see the problem re-occour. I'm just very interested in what explain then does if it is not only the time for the query plan. When I did try the "PREPARE / EXECUTE" dance as you described .. i didnt see the prepare state take time, which seems to be consistent with that the planning time is in the EXECUTE step according to the documentation. -- Jesper --------------080501010904040205050005 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
On 03/09/13 09:47, Craig Ringer wrote:
On 09/03/2013 03:46 PM, jesper@krogh.cc wrote:
Hi.

I have a strange situation where generating the query plan takes 6s+ and
executing it takes very little time.
How do you determine that it's planning time at fault here?
Not that I'm sure, but the timing I send were only for "explain" not "explain analyze". The database is constantly updating and at the moment i cannot reproduce it any more. But at the time I picked the numbers it were very reproducible.. (tried 10+ times over 15 minutes).

Please take separate timing for: PREPARE testq AS select table.id from db.table left join db.tablepro on db.id = tablepro.table_id where table.fts @@ to_tsquery('english','q12345') ; and then: EXPLAIN ANALYZE EXECUTE testq;
I'll try to do that if i see the problem re-occour. I'm just very interested in what explain then does if it is not only the time for the query plan. When I did try the "PREPARE / EXECUTE" dance as you described .. i didnt see the prepare state take time, which seems to be consistent with that the planning time is in the EXECUTE step according to the documentation.

--
Jesper
--------------080501010904040205050005--