Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 6E98963257E for ; Wed, 28 Apr 2010 04:49:34 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 09555-01 for ; Wed, 28 Apr 2010 07:49:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f216.google.com (mail-bw0-f216.google.com [209.85.218.216]) by mail.postgresql.org (Postfix) with ESMTP id 1DEC7632527 for ; Wed, 28 Apr 2010 04:49:26 -0300 (ADT) Received: by bwz8 with SMTP id 8so13017669bwz.3 for ; Wed, 28 Apr 2010 00:49:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=tOTY0eDh/xsOMGMO4l//JICKy1UItco/zlALj9uM2Bs=; b=ESqxAWN2f6K3twW3V51x6PZwUnTt9y5Je3cAt31jEb7Oz/gonBLN+O/eHcpJ0Z+j7S mVulgLMTg8alyxdey0jT6xl0Ic9bASbJkcHbwhHHHQ+H9g3oFlWMYh49pWLr8bT8LuTj PAZ3ic4caoScH/CKMyQtGCDixMWN2b4O44MGM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=BEsxWYU6+bHfYBZdZO4avselhOliY6g6mNd/o0fcoGB/aGT8QTILGCYZds94ooBDUr kMVpK9saG8hIhT8Bc7XDSZkveVaU0MdUhr00cOjdrjzbLqpoQtGXOr/obT5IKRbeXbXY xeYUMs+2jb0Vs/e93IGSfvic/GO2Mx0KDQXSY= Received: by 10.239.182.82 with SMTP id p18mr641835hbg.31.1272440965161; Wed, 28 Apr 2010 00:49:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.239.158.134 with HTTP; Wed, 28 Apr 2010 00:49:05 -0700 (PDT) In-Reply-To: References: <4BD0161A.4010908@dc.baikal.ru> <4BD0430C.1050308@2ndquadrant.com> <4BD10805.9060004@dc.baikal.ru> <4BD4FFE7.9090305@dc.baikal.ru> From: =?ISO-8859-1?Q?C=E9dric_Villemain?= Date: Wed, 28 Apr 2010 09:49:05 +0200 Message-ID: Subject: Re: Optimization idea To: Robert Haas Cc: Vlad Arkhipov , pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.499 tagged_above=-10 required=5 tests=BAYES_05=-0.5, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201004/325 X-Sequence-Number: 38575 2010/4/28 Robert Haas : > On Mon, Apr 26, 2010 at 5:33 AM, C=E9dric Villemain > wrote: >> In the first query, the planner doesn't use the information of the 2,3,4= . >> It just does a : I'll bet I'll have 2 rows in t1 (I think it should >> say 3, but it doesn't) >> So it divide the estimated number of rows in the t2 table by 5 >> (different values) and multiply by 2 (rows) : 40040. > > I think it's doing something more complicated. =A0See scalararraysel(). Thank you for driving me to the right function, Robert. It is in fact more complicated :) > >> In the second query the planner use a different behavior : it did >> expand the value of t1.t to t2.t for each join relation and find a >> costless plan. (than the one using seqscan on t2) > > I think the problem here is one we've discussed before: if the query > planner knows that something is true of x (like, say, x =3D > ANY('{2,3,4}')) and it also knows that x =3D y, it doesn't infer that > the same thing holds of y (i.e. y =3D ANY('{2,3,4}') unless the thing > that is known to be true of x is that x is equal to some constant. > Tom doesn't think it would be worth the additional CPU time that it > would take to make these sorts of deductions. =A0I'm not sure I believe > that, but I haven't tried to write the code, either. If I understand correctly, I did have some issues with exclusion_constraint=3D ON for complex queries in datamining where the planner failled to understand it must use only one partition because the where clause where not enough 'explicit'. But it's long time ago and I don't have my use case. We probably need to find some real case where the planner optimisation make sense. But I don't want usual queries to see their CPU time increase... Do we need real Planner Hints ? --=20 C=E9dric Villemain