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 1mREL4-0000cH-PW for pgsql-general@arkaria.postgresql.org; Fri, 17 Sep 2021 13:55:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mREL1-0004fl-G2 for pgsql-general@arkaria.postgresql.org; Fri, 17 Sep 2021 13:55:35 +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 1mREL1-0004fc-53 for pgsql-general@lists.postgresql.org; Fri, 17 Sep 2021 13:55:35 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mREKy-0007qc-Gf for pgsql-general@lists.postgresql.org; Fri, 17 Sep 2021 13:55:34 +0000 Received: by mail-ed1-x529.google.com with SMTP id c22so30345755edn.12 for ; Fri, 17 Sep 2021 06:55:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=JHWE9qPXngfTfjsBq5Fd+S0uoRWw1Jjkp2Aq5apv1dc=; b=hzD1y1cCsWlrKyyWINUf0ctPcYdrFgNeTIbdJjqDomImTWKOvtVsz6/C2LSn64/PUT TVwcYIqwrnuo592DGbUfpizJYZOmHpoRPHRYHOm5zfyTfEFmrWffkEuYyntlJ2AMsH79 YJGAjbxH4M+fVldseE07+bSCJDcfUnHnTmOOmQHnoyl2zmvHT9LV/u25Lim1pedlPO1l Va211B+3iCX9m1F7Kl1EaCtwdL5pBaiIUKKFc1cKqlkme6RmMaFXU3Zt/riAUu2bE6uU nMxVxhMEP2A1xdmB6koqkC78xHK6FCSsp48MRzsSt33VmtwVFdpGCs/JiVK7VI81Xv1O RJWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=JHWE9qPXngfTfjsBq5Fd+S0uoRWw1Jjkp2Aq5apv1dc=; b=LOoFuIlJAfQ+t91SwOkzoa+6LJzAzycy1XokHEJV1sfegxYs9F9ipInzBnbuP0sX0S BB5eRQOWqA0rnw9Yv9jsXzyGVuGdrJmjf1zgW5FpnMqvU8vCjkogDugkj1jPGyYIMZbR ZVDBgkbCaNRIyKEMBwx/8Q3xoAEGu3UBC4xzK1sseSNBbtUQF6CzdCKfurgxAWK2+TBU O1Q8VkLQsqyNpDOi9EqCjrnChlF1PKjN7ss5CFVH9gtI7D/nBg++FQhduc7jxbdpxnIV lnPXhOuVq7D0kS+Qt3aOXMgDmXeEee9ipE836Cvf4k/nGWsn5iUXL0VhQu+piWmkLNSc 9ZFw== X-Gm-Message-State: AOAM531XJAtax63mAVXR1ga1zJoegTeeqGSmUa/J8FDa8IJyDR89BGo3 Uu1TNJLppiWWmZeO5McGrv9YuElQNVE= X-Google-Smtp-Source: ABdhPJxMi/r7oenQbKWlLYrnQD8YXXJZuQJ+6SH1j+rmZVXUTyqb9xqZl2ZAMAvGwDq0ZwMOKkRKeA== X-Received: by 2002:a17:906:49d0:: with SMTP id w16mr12082932ejv.455.1631886930677; Fri, 17 Sep 2021 06:55:30 -0700 (PDT) Received: from localhost.localdomain (ip-85-160-5-181.eurotel.cz. [85.160.5.181]) by smtp.gmail.com with ESMTPSA id 11sm2346206ejw.50.2021.09.17.06.55.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Sep 2021 06:55:30 -0700 (PDT) To: pgsql-general@lists.postgresql.org From: ramikvl@gmail.com Subject: jsonb Indexing Message-ID: <3c162c26-e940-e49e-a465-6d484b0ca3a9@gmail.com> Date: Fri, 17 Sep 2021 15:55:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, I'm new to jsonb feature of postgres. I have PostgreSQL 13.2 running locally in docker. I've been playing a little bit with jsonb indexes described https://www.postgresql.org/docs/13/datatype-json.html#JSON-INDEXING and I'm not able make the GIN index work on 'tags'. I was wondering what I'm doing wrong. There are steps what I've tried: CREATE TABLE api (     jdoc jsonb ); INSERT INTO api (jdoc)     VALUES ('{     "guid": "9c36adc1-7fb5-4d5b-83b4-90356a46061a",     "name": "Angela Barton",     "is_active": true,     "company": "Magnafone",     "address": "178 Howard Place, Gulf, Washington, 702",     "registered": "2009-11-07T08:53:22 +08:00",     "latitude": 19.793713,     "longitude": 86.513373,     "tags": [         "enim",         "aliquip",         "qui"     ] }'); CREATE INDEX idxgintags ON api USING GIN ((jdoc->'tags')); EXPLAIN ANALYZE SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc -> 'tags' ? 'qui'; And the result is Seq Scan on api  (cost=0.00..1.02 rows=1 width=64) (actual time=0.019..0.021 rows=1 loops=1)   Filter: ((jdoc -> 'tags'::text) ? 'qui'::text) Planning Time: 0.115 ms Execution Time: 0.047 ms Do you know why Index Scan on idxgintag is not used? Thank you, Vlasta