Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 7908F63286E for ; Fri, 16 Apr 2010 12:34:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 12711-05 for ; Fri, 16 Apr 2010 15:33:48 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f220.google.com (mail-ew0-f220.google.com [209.85.219.220]) by mail.postgresql.org (Postfix) with ESMTP id 8AA2B632538 for ; Fri, 16 Apr 2010 12:33:48 -0300 (ADT) Received: by ewy20 with SMTP id 20so977628ewy.21 for ; Fri, 16 Apr 2010 08:33:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=QngQDLFEKSWsdTlm+aVulXXSVBCOFPomBTI6BB3nlCI=; b=KEnPUvQfFi5seqGvsxnPYWIZ3bpsbK5PZ2FWFQ0zzz+MvWCwINwqvbQa2nHvVOPZKe xJ6EM1btow9DMtO/6W+W0+rMTfTlbl6ntVx6XFepYQlHuiQp8TfXbuIMFz06BgLCLGLJ Qci7GFFomRIcQ0UCmvJuBiSS2QEvDSlw2RL1k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=G9/hn5wSukuxCFABoabep7zpwrQFYRWuufh5VO8a2avfwiRbweBugQqL/g4VV2pFQv hKQpEiZLQ3pgg398Vxr01GP7+6iOsjvvgAY7rQllB08K1hJ6+36YL3aQVTZter0uxzmz IhX9t/WcezxIO8BIQerSYjX73kDmbsIYcaGao= Received: by 10.213.68.77 with SMTP id u13mr305955ebi.9.1271432027318; Fri, 16 Apr 2010 08:33:47 -0700 (PDT) Received: from [0.0.0.0] (5357DA75.cable.casema.nl [83.87.218.117]) by mx.google.com with ESMTPS id 13sm1805341ewy.9.2010.04.16.08.33.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 16 Apr 2010 08:33:46 -0700 (PDT) Message-ID: <4BC88364.9050404@gmail.com> Date: Fri, 16 Apr 2010 17:33:56 +0200 From: Yeb Havinga User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Tom Lane CC: =?UTF-8?B?0JLRltGC0LDQu9GW0Lkg0KLQuNC80YfQuNGI0LjQvQ==?= , pgsql-performance@postgresql.org Subject: Re: Planner not using column limit specified for one column for another column equal to first References: <8534.1271427587@sss.pgh.pa.us> In-Reply-To: <8534.1271427587@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.856 tagged_above=-10 required=5 tests=AWL=0.044, BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201004/209 X-Sequence-Number: 38459 Tom Lane wrote: > =?KOI8-U?B?96bUwcymyiD0yc3eydvJzg==?= writes: > >> I've thought and someone in this list've told me that this should be done >> automatically. >> > > No, that's not true. We do make deductions about transitive equalities, > ie, given WHERE a=b AND b=c the planner will infer a=c and use that if > it's helpful. We don't make deductions about inequalities such as a>c. > In theory there's enough information available to do so, but overall > trying to do that would probably waste more cycles than it would save. > You'd need a lot of expensive new planner infrastructure, and in the > vast majority of queries it wouldn't produce anything very helpful. > New expensive planner infrastructure to support from a>b and b>c infer a>c, yes. But I wonder if something like Leibniz's principle of identity holds for members of the same equivalence class, e.g. like if x,y are both members of the same EC, then for every predicate P, P(x) iff P(y). Probably not for every predicate (like varno = 2 or attname='x'), but for the query evaluation, the object denoted by the variables are the same, since that is the standard meaning of the = operator. I cannot think of any standard (btree) operator where 'Leibniz' would fail in this case. regards, Yeb Havinga