Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YGYb0-0006EB-8L for pgsql-performance@arkaria.postgresql.org; Wed, 28 Jan 2015 19:48:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YGYaz-0002jL-B6 for pgsql-performance@arkaria.postgresql.org; Wed, 28 Jan 2015 19:48:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YGYay-0002jE-7x for pgsql-performance@postgresql.org; Wed, 28 Jan 2015 19:48:12 +0000 Received: from mail-wi0-f173.google.com ([209.85.212.173]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YGYat-0001MV-R1 for pgsql-performance@postgresql.org; Wed, 28 Jan 2015 19:48:11 +0000 Received: by mail-wi0-f173.google.com with SMTP id r20so14410151wiv.0 for ; Wed, 28 Jan 2015 11:48:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:organization:user-agent :mime-version:to:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=SdUob1ViiSsDA4m1RbPpXHUoJmY355U/Fl/jYwT3YFU=; b=PzTaYGC4XqrlKq8rR/t9Pl9TSOSlbGX/Aelsvp18N07zscWPU2lxiR5/laqxK9OEuo 0Z7r574SKrccbHuHsBLLa2dcfw75lAy8E/LRfdxz3+w4Yqvd9Ht9rEYJoL/PKg8LiJPT 43xdP87ZCwJurTIo3BbyvEPsT6UCGq/tFwfy+wm9S3T0tQnmDqRpbev+fkoSTqSvWOPm q/0SXVa29UoGvsjICz7vO2D9mqXbLyLcX1ypOciaSbkx6hE1S/svsRRMjP81zpW9jbH0 li3ryFX6oIGWs/CCePoBfHnlMfgctXX6WsGqbjUwdQdGxkNWF/gB8nTUcRjrDJsdd0Pe qjNA== X-Gm-Message-State: ALoCoQn13QVOKFOmC4YSLYelv5mk3Swmq3B0cv/JC++TE0WMKoXiES93z1NMyXgchwNCzdRPs2BO50OsiYnm0/EEqRyEB8+X6jFgE6XFnVqBvu0j/WB5SAVfsfONISLkvM2pKwM49FIcxG+Y3rgRdTXUvGahOZbH2DaR6OX/mNbgrZjsmSjwBgSKBTIfpn10BkDfepGef89t X-Received: by 10.180.211.34 with SMTP id mz2mr10327120wic.18.1422474486228; Wed, 28 Jan 2015 11:48:06 -0800 (PST) Received: from [192.168.1.163] (ip-78-45-139-138.net.upcbroadband.cz. [78.45.139.138]) by mx.google.com with ESMTPSA id l6sm7423205wjx.33.2015.01.28.11.48.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jan 2015 11:48:05 -0800 (PST) Message-ID: <54C93CF2.3020600@2ndquadrant.com> Date: Wed, 28 Jan 2015 20:48:02 +0100 From: Tomas Vondra Organization: 2ndQuadrant User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: working around JSONB's lack of stats? References: <54C738E1.8080405@agliodbs.com> In-Reply-To: <54C738E1.8080405@agliodbs.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) 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 27.1.2015 08:06, Josh Berkus wrote: > Folks, > ... > > On a normal column, I'd raise n_distinct to reflect the higher > selecivity of the search terms. However, since @> uses contsel, > n_distinct is ignored. Anyone know a clever workaround I don't > currently see? I don't see any reasonable workaround :-( ISTM we'll have to invent a way to collect useful stats about contents of JSON/JSONB documents. JSONB is cool, but at the moment we're mostly relying on defaults that may be reasonable, but still misfire in many cases. Do we have any ideas of how that might work? We're already collecting stats about contents of arrays, and maybe we could do something similar for JSONB? The nested nature of JSON makes that rather incompatible with the flat MCV/histogram stats, though. regards -- Tomas Vondra http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance