Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UNpU4-0006HQ-6h for pgsql-performance@arkaria.postgresql.org; Thu, 04 Apr 2013 19:06:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UNpU3-0000Om-HF for pgsql-performance@arkaria.postgresql.org; Thu, 04 Apr 2013 19:06:03 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UNpU2-0000Oh-E5 for pgsql-performance@postgresql.org; Thu, 04 Apr 2013 19:06:02 +0000 Received: from mail-ye0-f172.google.com ([209.85.213.172]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UNpTz-0005HE-Dn for pgsql-performance@postgresql.org; Thu, 04 Apr 2013 19:06:01 +0000 Received: by mail-ye0-f172.google.com with SMTP id l13so479362yen.3 for ; Thu, 04 Apr 2013 12:05:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:references:mime-version:in-reply-to:content-type :content-transfer-encoding:message-id:cc:x-mailer:from:subject:date :to; bh=GMfVChFtzQBAXyUOyI52DEGONiYplZ52/hLdFYYhCb8=; b=dpjlwg1IyvH6xyhxJtH84vacg6asnRqi8imtye7DNzFaWk1fP4tBfDCpYOGkKCl/Wg PwNgl3/jpvAxwbY1FcBCSSxdwP3lHpDxbKnUsme+8OVqs4iLa7CJF2LFWOMvg4cFJUUD hgWl7TtR+IO9WbHyQVqupq0xFY5+0OaLKnr3DZjdHZRa8WOcteUe+xT+oXnpnP0D+3gL O5Dlgqcmqf5LxN25Ayk22srkY7DL7/YFfCp2xEMvxXHQmooBjAjiGTiWstxWU2LeEaUK w2caBLj1B73vUhvMg/0HANW8UMny4mhjzs9IWsrMihJ1oiODVAuB4dGMq4vrI0nDQV8s gAWg== X-Received: by 10.236.134.38 with SMTP id r26mr4722891yhi.9.1365102358658; Thu, 04 Apr 2013 12:05:58 -0700 (PDT) Received: from [10.224.184.129] (27.sub-174-254-144.myvzw.com. [174.254.144.27]) by mx.google.com with ESMTPS id v48sm16942403yhi.26.2013.04.04.12.05.56 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Apr 2013 12:05:57 -0700 (PDT) References: <515D92BF.5000309@axege.com> <515D9FC5.7030105@axege.com> <18910.1365092713@sss.pgh.pa.us> <515DCB34.6040801@axege.com> Mime-Version: 1.0 (1.0) In-Reply-To: <515DCB34.6040801@axege.com> Content-Type: multipart/alternative; boundary=Apple-Mail-AA5E1231-DC1A-423D-BCEB-61C9E9380FC4 Content-Transfer-Encoding: 7bit Message-Id: <341110C9-21FF-4379-9103-B58B60F81138@gmail.com> Cc: "pgsql-performance@postgresql.org" X-Mailer: iPhone Mail (10B329) From: nik9000@gmail.com Subject: Re: What happens between end of explain analyze and end of query execution ? Date: Thu, 4 Apr 2013 15:05:52 -0400 To: Franck Routier X-Pg-Spam-Score: -2.4 (--) 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 --Apple-Mail-AA5E1231-DC1A-423D-BCEB-61C9E9380FC4 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Apr 4, 2013, at 2:49 PM, Franck Routier wrote:= > Le 04/04/2013 18:25, Tom Lane a =C3=A9crit : >> Franck Routier writes: >>> Right, explain alone takes 3.6 seconds, so the time really seems to go=20= >>> query planning... >> Well, you've not shown us the query, so it's all going to be >> speculation. But maybe you have some extremely expensive function that >> the planner is evaluating to fold to a constant, or something like that? >> The generated plan isn't terribly complicated, but we can't see what >> was required to produce it. >>=20 >> regards, tom lane >>=20 >>=20 > The request is not using any function. It looks like this: >=20 > SELECT * > FROM sanrss > LEFT JOIN sanrum ON sanrum.sanrum___rforefide =3D sanrss.sanrss_= __rforefide AND sanrum.sanrum___rfovsnide =3D sanrss.sanrss___rfovsnide AND s= anrum.sanrum___sanrsside =3D sanrss.sanrsside > LEFT JOIN sanact ON sanact.sanact___rforefide =3D sanrum.sanr= um___rforefide AND sanact.sanact___rfovsnide =3D sanrum.sanrum___rfovsnide A= ND sanact.sanact___sanrsside =3D sanrum.sanrum___sanrsside AND sanact.sanact= ___sanrumide =3D sanrum.sanrumide AND sanact.sanact___sanrumide IS NOT NUL= L AND sanact.sanact___rsanopide=3D'CCAM' > LEFT JOIN sandia ON sandia.sandia___rforefide =3D sanrum.sanr= um___rforefide AND sandia.sandia___rfovsnide =3D sanrum.sanrum___rfovsnide A= ND sandia.sandia___sanrsside =3D sanrum.sanrum___sanrsside AND sandia.sandia= ___sanrumide =3D sanrum.sanrumide AND sandia.sandiasig=3D1 > LEFT JOIN saneds ON sanrss.sanrss___rforefide =3D saneds.sane= ds___rforefide AND sanrss.sanrss___rfovsnide =3D saneds.saneds___rfovsnide A= ND sanrss.sanrss___sanedside =3D saneds.sanedside > LEFT JOIN rsaidp ON saneds.saneds___rforefide =3D rsaidp.rsai= dp___rforefide AND saneds.saneds___rsaidpide =3D rsaidp.rsaidpide > WHERE sanrss.sanrss___rforefide =3D 'CHCL' AND sanrss.sanr= ss___rfovsnide =3D '201012_600' AND sanrss.sanrsside =3D '1188100' > ORDER BY sanrum.sanrumord, sanrum.sanrumide >=20 > Schema looks like this : > rsaidp > | > v > sanrss -------- > | | > v v > sanrum sandia > | > v > sanact >=20 >=20 > Primary keys are most made of several varchars. Foreign keys do exist. Que= ry is getting these data for one specific sanrss. > This used to take around 50ms to execute, and is now taking 3.5 seconds. A= nd it looks like this is spent computing a query plan... >=20 > I also tried: PREPARE qry(id) as select .... > The prepare takes 3.5 seconds. Execute qry(value) takes a few milliseconds= ... >=20 > Regards, > Franck Is it only this query or all queries?= --Apple-Mail-AA5E1231-DC1A-423D-BCEB-61C9E9380FC4 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Apr 4, 2013, at 2= :49 PM, Franck Routier <franc= k.routier@axege.com> wrote:

=20 =20 =20
Le 04/04/2013 18:25, Tom Lane a =C3=A9cri= t :
Franck Routier <franck.routier@axege.com> write=
s:
Right, explain alone takes 3.6 seconds, so the time r=
eally seems to go=20
query planning...
Well, you've not shown us the query, so it's all going t=
o be
speculation.  But maybe you have some extremely expensive function that
the planner is evaluating to fold to a constant, or something like that?
The generated plan isn't terribly complicated, but we can't see what
was required to produce it.

			regards, tom lane


The request is not using any function. It looks like this:<= br>
SELECT *
         FROM sanrss
         LEFT JOIN sanrum&nb= sp; ON sanrum.sanrum___rforefide =3D sanrss.sanrss___rforefide AND sanrum.sanrum___rfovsnide =3D sanrss.sanrss___rfovsnide AND sanrum.sanrum___sanrsside =3D sanrss.sanrsside
            L= EFT JOIN sanact  ON sanact.sanact___rforefide =3D sanrum.sanrum___rforefide AND sanact.sanact___rfovsnide =3D sanrum.sanrum___rfovsnide AND sanact.sanact___sanrsside =3D sanrum.sanrum___sanrsside AND sanact.sanact___sanrumide =3D sanrum.sanrumide AND sanact.sanact___sanrumide   IS NOT NU= LL AND sanact.sanact___rsanopide=3D'CCAM'
            L= EFT JOIN sandia  ON sandia.sandia___rforefide =3D sanrum.sanrum___rforefide AND sandia.sandia___rfovsnide =3D sanrum.sanrum___rfovsnide AND sandia.sandia___sanrsside =3D sanrum.sanrum___sanrsside AND sandia.sandia___sanrumide =3D sanrum.sanrumide AND sandia.sandiasig=3D1
            L= EFT JOIN saneds  ON sanrss.sanrss___rforefide =3D saneds.saneds___rforefide AND sanrss.sanrss___rfovsnide =3D saneds.saneds___rfovsnide AND sanrss.sanrss___sanedside =3D saneds.sanedside
            L= EFT JOIN rsaidp  ON saneds.saneds___rforefide =3D rsaidp.rsaidp___rforefide AND saneds.saneds___rsaidpide =3D rsaidp.rsaidpide
           &n= bsp;  WHERE sanrss.sanrss___rforefide =3D  'CHCL'  AND sanrss.sanrss___rfovsnide =3D  '201012_600'  AND sanrss.sa= nrsside =3D  '1188100'
         ORDER BY sanrum.san= rumord, sanrum.sanrumide


Schema looks like this :
rsaidp
 |
 v
sanrss --------
 |          &nb= sp; |
 v          &nb= sp; v
sanrum       sandia
 |
 v
sanact


Primary keys are most made of several varchars. Foreign keys do exist. Query is getting these data for one specific sanrss.
This used to take around 50ms to execute, and is now taking 3.5 seconds. And it looks like this is spent computing a query plan...

I also tried: PREPARE qry(id) as select ....
The prepare takes 3.5 seconds. Execute qry(value) takes a few milliseconds...

Regards,
Franck
=20

Is it only this query or all queries?
= --Apple-Mail-AA5E1231-DC1A-423D-BCEB-61C9E9380FC4--