Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id EA51C1337B61 for ; Wed, 4 May 2011 11:13:06 -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 46393-02 for ; Wed, 4 May 2011 14:12:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 1050D1337B47 for ; Wed, 4 May 2011 11:12:48 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p44ECnSH010498; Wed, 4 May 2011 10:12:49 -0400 (EDT) To: Denis de Bernardy cc: "pgsql-performance@postgresql.org" Subject: Re: row estimate very wrong for array type In-reply-to: <625605.72736.qm@web112406.mail.gq1.yahoo.com> References: <625605.72736.qm@web112406.mail.gq1.yahoo.com> Comments: In-reply-to Denis de Bernardy message dated "Wed, 04 May 2011 06:40:50 -0700" Date: Wed, 04 May 2011 10:12:49 -0400 Message-ID: <10497.1304518369@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/50 X-Sequence-Number: 43559 Denis de Bernardy writes: > [ estimates for array && suck ] > Might this be a bug in the operator's selectivity, or am I doing something wrong? Array && uses areasel() which is only a stub :-( In the particular case here it'd be possible to get decent answers just by trying the operator against all the MCV-list entries, but it's unlikely that that would fix things for enough people to be worth the trouble. Really you'd need to maintain statistics about the element values appearing in the array column in order to get useful estimates for && queries. Jan Urbanski did something similar for tsvector columns a year or two ago, but nobody's gotten around to doing it for array columns. regards, tom lane