Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WjHab-0002EW-3L for pgsql-hackers@arkaria.postgresql.org; Sun, 11 May 2014 00:26:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WjHaa-000788-6T for pgsql-hackers@arkaria.postgresql.org; Sun, 11 May 2014 00:26:00 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WjHaY-00077x-L8 for pgsql-hackers@postgresql.org; Sun, 11 May 2014 00:25:58 +0000 Received: from mail-ob0-f176.google.com ([209.85.214.176]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WjHaQ-0006OS-Ur for pgsql-hackers@postgresql.org; Sun, 11 May 2014 00:25:57 +0000 Received: by mail-ob0-f176.google.com with SMTP id wo20so6562235obc.35 for ; Sat, 10 May 2014 17:25:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=TqXOIjzz3IGyR7b74d8TQ+tu6r1/v+kb+u5QFWXR7Cs=; b=Tdm/vdOeCNrWjx+VRiuCibPWJigvOWcvrxDZiRptT3cLlXnvXjkbpadk3Ne1qIe9t3 PlqNO95GkjVG8cvt6jhMNxMWFjnguYHoJ2EqvHYS8OTqobTP2m8q9Ojy/VSigPIYeE1S yf439St/nu1MB7BBXDzQ3nQGCp35h2hduIGATlYgnSfA3XrE4qoe8SVw5x/ebZog0Occ x6tLob6UDFghbImTDn7XHwar3/xPLG2R6A1QqUpC28vQNZzTbG2UCriWS0mRLkE6vfoN qETx6ItdiT9PLOR70NkJLhOhe+EtjqP1hksIE3vOzhOFBJuNlyYGaxLRZqmZdX7HEbqj FO3w== X-Gm-Message-State: ALoCoQkbteYSoe/s1PyLnoD3NStOriedtuq+qe97xcvLYvTCjneQ1l6s1a33y8P3qyz1VrLtUmm6 MIME-Version: 1.0 X-Received: by 10.183.3.102 with SMTP id bv6mr24373553obd.18.1399767949900; Sat, 10 May 2014 17:25:49 -0700 (PDT) Received: by 10.182.176.67 with HTTP; Sat, 10 May 2014 17:25:49 -0700 (PDT) In-Reply-To: References: <16769.1399407530@sss.pgh.pa.us> <20140506212020.GK30817@momjian.us> <57E8AA44-F816-45F2-BB61-5A854FFB0A97@justatheory.com> <28554.1399414853@sss.pgh.pa.us> <20140508134701.GO30817@momjian.us> <5819.1399558614@sss.pgh.pa.us> <1888.1399588751@sss.pgh.pa.us> <20140509033405.GA23254@momjian.us> <536C550F.50108@archidevsys.co.nz> <18360.1399633457@sss.pgh.pa.us> <20140509135336.GC23254@momjian.us> <28961.1399668272@sss.pgh.pa.us> <536E8F3A.40706@vmware.com> Date: Sat, 10 May 2014 17:25:49 -0700 Message-ID: Subject: Re: default opclass for jsonb (was Re: Call for GIST/GIN/SP-GIST opclass documentation) From: Peter Geoghegan To: Heikki Linnakangas Cc: Tom Lane , Greg Stark , Bruce Momjian , Gavin Flower , "David E. Wheeler" , Robert Haas , Andrew Dunstan , "pgsql-hackers@postgresql.org" Content-Type: multipart/mixed; boundary=001a1134a45c6c22ed04f914df32 X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --001a1134a45c6c22ed04f914df32 Content-Type: text/plain; charset=UTF-8 On Sat, May 10, 2014 at 2:52 PM, Peter Geoghegan wrote: > I've added a wildcard to the rhs jsonb here, which of course won't > work, the proximate cause being that that simply isn't valid jsonb. > It's also something inherently impossible to support with the current > jsonb_hash_op's indexing strategy. That only hashes elements and > values, mixing in keys from all outer nesting levels (so it's possible > for there to be 0 *nentries). It occurs to me that this could be a particular problem for jsonb_hash_ops. Consider this jsonb: '{"a":{}}'::jsonb In one sense, the outermost level's "a" key does have a value: an empty object. So we may test containment in an indexable fashion like this: select * from foo where j @> '{"a":{}}'::jsonb But in another sense, the sense that is relevant to jsonb_hash_ops, it does not. There would be *no* GIN keys passed back from gin_extract_jsonb_hash() if it were tasked with extracting keys from this rhs jsonb. Now, I'm not all that worried about this, because this is surely an odd-ball use case, particularly for jsonb_hash_ops where no keys are separately indexed (separately from *primitive* elements/values). However, it is worth noting in the documentation in my view. I attach a doc patch that adds this. -- Peter Geoghegan --001a1134a45c6c22ed04f914df32 Content-Type: text/x-patch; charset=US-ASCII; name="jsonb_structure_containment.patch" Content-Disposition: attachment; filename="jsonb_structure_containment.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hv1lm9am0 KioqIGEvZG9jL3NyYy9zZ21sL2pzb24uc2dtbAotLS0gYi9kb2Mvc3JjL3Nn bWwvanNvbi5zZ21sCioqKioqKioqKioqKioqKiBTRUxFQ1QgamRvYy0mZ3Q7 J2d1aWQnLCBqZG9jLSZndDsnbmFtZScKKioqIDQ1Myw0NTggKioqKgotLS0g NDUzLDQ2MyAtLS0tCiAgICAgIHBhcnRpY3VsYXJseSB3aGVuIHF1ZXJpZXMg Y29udGFpbiBrZXlzIHRoYXQgYXBwZWFyIGZyZXF1ZW50bHkgaW4gdGhlCiAg ICAgIGRhdGEuICBUaGVyZWZvcmUgc2VhcmNoIG9wZXJhdGlvbnMgdHlwaWNh bGx5IHBlcmZvcm0gYmV0dGVyCiAgICAgIHRoYW4gd2l0aCB0aGUgZGVmYXVs dCBvcGVyYXRvciBjbGFzcy4KKyAgICAgPGxpdGVyYWw+anNvbmJfaGFzaF9v cHM8L2xpdGVyYWw+IGluZGV4ZXMgYXJlIGlsbC1zdWl0ZWQgdG8gY2FzZXMK KyAgICAgd2hlcmUgdGhlcmUgYXJlIGZyZXF1ZW50IGNvbnRhaW5tZW50IHF1 ZXJpZXMgdGhhdCB0ZXN0IGNvbnRhaW5tZW50CisgICAgIG9mIGEgPHR5cGU+ anNvbmI8Lz4gPGVtcGhhc2lzPndpdGhvdXQ8Lz4gYW55IHByaW1pdGl2ZSBv YmplY3QKKyAgICAgdmFsdWVzIG9yIGFycmF5IGVsZW1lbnRzLCBhcyB3aGVu IHNlYXJjaGluZyBmb3IgSlNPTiBkb2N1bWVudHMKKyAgICAgbWF0Y2hpbmcg YSBwYXJ0aWN1bGFyIHN0cnVjdHVyZS4KICAgIDwvcGFyYT4KICAKICAgIDxw YXJhPgo= --001a1134a45c6c22ed04f914df32 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --001a1134a45c6c22ed04f914df32--