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 1nEojp-00058X-Ey for pgsql-sql@arkaria.postgresql.org; Tue, 01 Feb 2022 08:42:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nEojo-0000Pl-BG for pgsql-sql@arkaria.postgresql.org; Tue, 01 Feb 2022 08:42:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nEojn-0000Pc-UE for pgsql-sql@lists.postgresql.org; Tue, 01 Feb 2022 08:42:08 +0000 Received: from forward101p.mail.yandex.net ([2a02:6b8:0:1472:2741:0:8b7:101]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nEojk-0005qZ-5t for pgsql-sql@lists.postgresql.org; Tue, 01 Feb 2022 08:42:06 +0000 Received: from forward100q.mail.yandex.net (forward100q.mail.yandex.net [IPv6:2a02:6b8:c0e:4b:0:640:4012:bb97]) by forward101p.mail.yandex.net (Yandex) with ESMTP id 6249B59CE84F for ; Tue, 1 Feb 2022 11:42:00 +0300 (MSK) Received: from vla1-68d3ce55e22b.qloud-c.yandex.net (vla1-68d3ce55e22b.qloud-c.yandex.net [IPv6:2a02:6b8:c0d:3385:0:640:68d3:ce55]) by forward100q.mail.yandex.net (Yandex) with ESMTP id 5EEF76F40002 for ; Tue, 1 Feb 2022 11:42:00 +0300 (MSK) Received: from 2a02:6b8:c0d:3603:0:640:5413:378e (2a02:6b8:c0d:3603:0:640:5413:378e [2a02:6b8:c0d:3603:0:640:5413:378e]) by vla1-68d3ce55e22b.qloud-c.yandex.net (mxback/Yandex) with HTTP id xfMB1n0c0iE1-g0c4XjRk; Tue, 01 Feb 2022 11:42:00 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1643704920; bh=tOV4FZV8z0YbQCBK+V9u3c55pWz/5Io1cU4+lUzCrh0=; h=Message-Id:Date:To:From; b=kjkXp10I2y10ddbQZ0sgQ8UQnCk5d3JgGjK72StRx5KfMnH2G4PeI5PLmNSEIxxZx Z7hujmS7F78Se8aVbuHndnQh+K+oNCROaMdfpwTLykrW/ydXO7+V+XTYaXKKA2uwOe 0y4OSZW8oE//b9rWphJNHOHLVicwwjiy+YXCoLc0= Authentication-Results: vla1-68d3ce55e22b.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Received: by vla1-5413378edd9f.qloud-c.yandex.net with HTTP; Tue, 01 Feb 2022 11:42:00 +0300 From: =?utf-8?B?0JTQvNC40YLRgNC40Lkg0JLQvtGA0L7QvdC40L0=?= To: "pgsql-sql@lists.postgresql.org" MIME-Version: 1.0 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Tue, 01 Feb 2022 11:42:00 +0300 Message-Id: <506811643704589@mail.yandex.ru> Content-Transfer-Encoding: 8bit Content-Type: text/html; charset=utf-8 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk
Hi all,
 
I'm using PostgreSQL 13.
 
I have a table:
 
CREATE TABLE test(docid integer, jsonb attrs);
 
So, attrs contains data like
 
...
"dates": ["2019-10-02", "2018-02-03"]
...
 
So, I want to SELECT all docids, which dates in range:
 
SELECT attrs FROM document_resinfo WHERE attrs @? '$.dates[*].datetime() ? (@ >= "2020-10-02".datetime())';
 
How can I create index on attrs field to query docids with other date? Thanks.
 
-- 
Best regards, Dmitry Voronin