Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z2lrI-00016C-El for pgsql-performance@arkaria.postgresql.org; Wed, 10 Jun 2015 19:40:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Z2lrH-0007ge-Vm for pgsql-performance@arkaria.postgresql.org; Wed, 10 Jun 2015 19:40:20 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Z2lrH-0007gV-4K for pgsql-performance@postgresql.org; Wed, 10 Jun 2015 19:40:19 +0000 Received: from 01.zmailcloud.com ([192.198.85.104] helo=mx-out-1.zmailcloud.com) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1Z2lrE-0004cJ-4V for pgsql-performance@postgresql.org; Wed, 10 Jun 2015 19:40:17 +0000 Received: from smtp.01.com (smtp.01.com [10.10.0.43]) by mx-out-1.zmailcloud.com (Postfix) with ESMTP id 775C2564486; Wed, 10 Jun 2015 14:40:15 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by smtp-out-1.01.com (Postfix) with ESMTP id 5CFFAA0285; Wed, 10 Jun 2015 14:40:15 -0500 (CDT) X-Virus-Scanned: amavisd-new at smtp-out-1.01.com Received: from smtp.01.com ([127.0.0.1]) by localhost (smtp-out-1.01.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2iEwDONLtTrj; Wed, 10 Jun 2015 14:40:15 -0500 (CDT) Received: from smtp.01.com (localhost [127.0.0.1]) by smtp-out-1.01.com (Postfix) with ESMTP id 25F48A03BC; Wed, 10 Jun 2015 14:40:15 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by smtp-out-1.01.com (Postfix) with ESMTP id F0846A02E3; Wed, 10 Jun 2015 14:40:14 -0500 (CDT) X-Virus-Scanned: amavisd-new at smtp-out-1.01.com Received: from smtp.01.com ([127.0.0.1]) by localhost (smtp-out-1.01.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id zJBxCVxVsBs7; Wed, 10 Jun 2015 14:40:14 -0500 (CDT) Received: from [172.47.23.103] (50-0-190-244.dsl.dynamic.fusionbroadband.com [50.0.190.244]) by smtp-out-1.01.com (Postfix) with ESMTPSA id 3CB4BA0285; Wed, 10 Jun 2015 14:40:14 -0500 (CDT) Message-ID: <5578929B.6060400@agliodbs.com> Date: Wed, 10 Jun 2015 12:40:11 -0700 From: Josh Berkus Organization: PostgreSQL Experts Inc. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Merlin Moncure , Patrick Krecker CC: postgres performance list Subject: Re: Row estimates off by two orders of magnitude with hstore References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) 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 On 06/10/2015 11:32 AM, Merlin Moncure wrote: > This is a fundamental issue with using 'database in a box' datatypes > like hstore and jsonb. They are opaque to the statistics gathering > system and so are unable to give reasonable estimates beyond broad > assumptions. Speaking generally, the workarounds are too: > > *) disable particular plan choices for this query > (materialize/nestloop are common culprits) > > *) create btree indexes around specific extraction clauses > > *) refactor some of the query into set returning function with a > custom ROWS clause > > *) try alternate indexing strategy such as jsonb/jsquery > > *) move out of hstore and into more standard relational strucure You forgot: *) Fund a PostgreSQL developer to add selectivity estimation and stats to hstore. -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance