Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBdO0-0005fp-Cx for pgsql-docs@arkaria.postgresql.org; Mon, 15 Feb 2021 12:53:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lBdNy-0003Yz-1i for pgsql-docs@arkaria.postgresql.org; Mon, 15 Feb 2021 12:53:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBdNx-0003Yq-NL for pgsql-docs@lists.postgresql.org; Mon, 15 Feb 2021 12:53:53 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lBdNu-0005fi-IN for pgsql-docs@lists.postgresql.org; Mon, 15 Feb 2021 12:53:53 +0000 Received: by mail-ej1-x62a.google.com with SMTP id w1so1785614ejk.6 for ; Mon, 15 Feb 2021 04:53:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=XuAjQMGXTC2joqoOwChXsm3syuLMQxqyQjuz3Nlfczw=; b=Aq6V9qGUX7dzVrpiQJ0um5mzR9KM9AiPUyrwFmys8Y6WgEhVzO9Rf54TVxEH+5HfCy ObPDEIfT5iapsdzb5bLnnqJ+51mvmjLfC1MFD1N7DhqAAG7iniyUoOzO0QY6ZrXaY/uf 1/unvYqBeFjEXyC4VbKaUi3oMzTLfONqic2RZgUmcoNPxZJm5ahU5kfbPjhRgrphuJh1 1Yl+kKC7mEq1pefbtPzWskLt8vL0JZlOnr/LVfd/+41ANy5V1hQGk85urZNy+xJTsXGv nlTUSwOTImO/QZwxPyoZEPrMif62EsL3jkvoFp64pqkIwp3+ieSbK6/BI8/8fRe6yfMX z5JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=XuAjQMGXTC2joqoOwChXsm3syuLMQxqyQjuz3Nlfczw=; b=TjlkhnbaNdIAdreOP9PFoy7Pw0FT4hN+0CMvSHgXpqkgKSug0nF+iueJW0ZWW7AJ6z o4wcxHCdgIm1VMA44tVBzAgYslPOmzLq+Cn7Isr1Fqgr0fsg7Zv1j5fbHfN3ojVr+RvL 3vWYk7KWnthwAhMb4WI5+rjiP8T9KrpLGAvu1L4urKfXfhPftLKbOtUexhAFo2/Co40S wyfqr+e2bGIQYHbO4z6eVqXquDGaiQuT+Bfh4jOZQ1MV61lw2Cuit9unDUVekoFtwv4V KpwcHbS/QYI7ewofpQ4Rx1rhloFsXS7aOvDpXQePAIQldnQBOJAVJ1s7qIsXSZGz89Wy lXxw== X-Gm-Message-State: AOAM531hezS1HMlamGh4SrwaubFU3/VpZF2SKG4pjxTVDUAQR5sQ+GCz Lf7xGecrcUkhmNC/2ROVwVEGTw== X-Google-Smtp-Source: ABdhPJwo8xhA9CHce3a6QA2Kt+kIju9Xk+PYeF/kDUuVLopUeVS76N2agGv2+JCKkbsvFv0IQCJAPw== X-Received: by 2002:a17:906:a948:: with SMTP id hh8mr15711900ejb.226.1613393628364; Mon, 15 Feb 2021 04:53:48 -0800 (PST) Received: from localhost.localdomain (217-149-170-190.nat.highway.telekom.at. [217.149.170.190]) by smtp.gmail.com with ESMTPSA id n2sm2806524edr.8.2021.02.15.04.53.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 04:53:48 -0800 (PST) Message-ID: <27b8149fad9bdf3efd96c7a69d91898e2734f98a.camel@cybertec.at> Subject: Re: Documentation on Hash and btree Indexes on jsonb From: Laurenz Albe To: holger.vornholt@deutschebahn.com, pgsql-docs@lists.postgresql.org Date: Mon, 15 Feb 2021 13:53:47 +0100 In-Reply-To: <161320903985.3454.7956608521954674568@wrigleys.postgresql.org> References: <161320903985.3454.7956608521954674568@wrigleys.postgresql.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat, 2021-02-13 at 09:37 +0000, PG Doc comments form wrote: > The documentation on https://www.postgresql.org/docs/12/datatype-json.html > claims: > "jsonb also supports btree and hash indexes. These are usually useful only > if it's important to check equality of complete JSON documents." > > According to some older information from 2016 > > https://bitnine.net/blog-postgresql/postgresql-internals-jsonb-type-and-its-indexes/?ckattempt=1 > https://stackoverflow.com/questions/36075918/postgresql-index-on-json > it seems to be a valid option to use hash or btree indexes in that case > however. > "As a result, in the choice of an index for JSONB type, if the index > searches a few predetermined attributes, BTREE is the best choice" > > The quoted sentance from the postgres documentation would suggest, that this > option could be discarded. I would love to hear your feedback on this > matter. The PostgreSQL documentation is talking about a B-tree index on the complete JSON, while the article is talking about a B-tree index on an expression that extracts one attribute of the JSON. These are quite different things, so both are correct. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com