@@ -1184,7 +1184,10 @@ SELECT gin_debug_query_path_value('x @> [1,2,3]');
1184
1184
SELECT gin_debug_query_path_value('x <@ [1,2,3]');
1185
1185
gin_debug_query_path_value
1186
1186
----------------------------
1187
- NULL +
1187
+ OR +
1188
+ x.# = 1 , entry 0 +
1189
+ x.# = 2 , entry 1 +
1190
+ x.# = 3 , entry 2 +
1188
1191
1189
1192
(1 row)
1190
1193
@@ -1293,7 +1296,10 @@ SELECT gin_debug_query_value_path('x @> [1,2,3]');
1293
1296
SELECT gin_debug_query_value_path('x <@ [1,2,3]');
1294
1297
gin_debug_query_value_path
1295
1298
----------------------------
1296
- NULL +
1299
+ OR +
1300
+ x.# = 1 , entry 0 +
1301
+ x.# = 2 , entry 1 +
1302
+ x.# = 3 , entry 2 +
1297
1303
1298
1304
(1 row)
1299
1305
@@ -1438,6 +1444,31 @@ select count(*) from test_jsquery where v @@ 'product_group = false';
1438
1444
1
1439
1445
(1 row)
1440
1446
1447
+ select v from test_jsquery where v @@ 'array <@ [2,3]' order by v;
1448
+ v
1449
+ -------------------
1450
+ {"array": [2]}
1451
+ {"array": [2, 3]}
1452
+ (2 rows)
1453
+
1454
+ select v from test_jsquery where v @@ 'array && [2,3]' order by v;
1455
+ v
1456
+ ----------------------
1457
+ {"array": [2]}
1458
+ {"array": [2, 3]}
1459
+ {"array": [1, 2, 3]}
1460
+ {"array": [2, 3, 4]}
1461
+ {"array": [3, 4, 5]}
1462
+ (5 rows)
1463
+
1464
+ select v from test_jsquery where v @@ 'array @> [2,3]' order by v;
1465
+ v
1466
+ ----------------------
1467
+ {"array": [2, 3]}
1468
+ {"array": [1, 2, 3]}
1469
+ {"array": [2, 3, 4]}
1470
+ (3 rows)
1471
+
1441
1472
create index t_idx on test_jsquery using gin (v jsonb_value_path_ops);
1442
1473
set enable_seqscan = off;
1443
1474
explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0';
@@ -1547,6 +1578,64 @@ select count(*) from test_jsquery where v @@ 'product_group = false';
1547
1578
1
1548
1579
(1 row)
1549
1580
1581
+ explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]' order by v;
1582
+ QUERY PLAN
1583
+ ---------------------------------------------------------------
1584
+ Sort
1585
+ Sort Key: v
1586
+ -> Bitmap Heap Scan on test_jsquery
1587
+ Recheck Cond: (v @@ '"array" <@ [2, 3]'::jsquery)
1588
+ -> Bitmap Index Scan on t_idx
1589
+ Index Cond: (v @@ '"array" <@ [2, 3]'::jsquery)
1590
+ (6 rows)
1591
+
1592
+ explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]' order by v;
1593
+ QUERY PLAN
1594
+ ---------------------------------------------------------------
1595
+ Sort
1596
+ Sort Key: v
1597
+ -> Bitmap Heap Scan on test_jsquery
1598
+ Recheck Cond: (v @@ '"array" && [2, 3]'::jsquery)
1599
+ -> Bitmap Index Scan on t_idx
1600
+ Index Cond: (v @@ '"array" && [2, 3]'::jsquery)
1601
+ (6 rows)
1602
+
1603
+ explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]' order by v;
1604
+ QUERY PLAN
1605
+ ---------------------------------------------------------------
1606
+ Sort
1607
+ Sort Key: v
1608
+ -> Bitmap Heap Scan on test_jsquery
1609
+ Recheck Cond: (v @@ '"array" @> [2, 3]'::jsquery)
1610
+ -> Bitmap Index Scan on t_idx
1611
+ Index Cond: (v @@ '"array" @> [2, 3]'::jsquery)
1612
+ (6 rows)
1613
+
1614
+ select v from test_jsquery where v @@ 'array <@ [2,3]' order by v;
1615
+ v
1616
+ -------------------
1617
+ {"array": [2]}
1618
+ {"array": [2, 3]}
1619
+ (2 rows)
1620
+
1621
+ select v from test_jsquery where v @@ 'array && [2,3]' order by v;
1622
+ v
1623
+ ----------------------
1624
+ {"array": [2]}
1625
+ {"array": [2, 3]}
1626
+ {"array": [1, 2, 3]}
1627
+ {"array": [2, 3, 4]}
1628
+ {"array": [3, 4, 5]}
1629
+ (5 rows)
1630
+
1631
+ select v from test_jsquery where v @@ 'array @> [2,3]' order by v;
1632
+ v
1633
+ ----------------------
1634
+ {"array": [2, 3]}
1635
+ {"array": [1, 2, 3]}
1636
+ {"array": [2, 3, 4]}
1637
+ (3 rows)
1638
+
1550
1639
drop index t_idx;
1551
1640
create index t_idx on test_jsquery using gin (v jsonb_path_value_ops);
1552
1641
set enable_seqscan = off;
@@ -1657,4 +1746,62 @@ select count(*) from test_jsquery where v @@ 'product_group = false';
1657
1746
1
1658
1747
(1 row)
1659
1748
1749
+ explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]' order by v;
1750
+ QUERY PLAN
1751
+ ---------------------------------------------------------------
1752
+ Sort
1753
+ Sort Key: v
1754
+ -> Bitmap Heap Scan on test_jsquery
1755
+ Recheck Cond: (v @@ '"array" <@ [2, 3]'::jsquery)
1756
+ -> Bitmap Index Scan on t_idx
1757
+ Index Cond: (v @@ '"array" <@ [2, 3]'::jsquery)
1758
+ (6 rows)
1759
+
1760
+ explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]' order by v;
1761
+ QUERY PLAN
1762
+ ---------------------------------------------------------------
1763
+ Sort
1764
+ Sort Key: v
1765
+ -> Bitmap Heap Scan on test_jsquery
1766
+ Recheck Cond: (v @@ '"array" && [2, 3]'::jsquery)
1767
+ -> Bitmap Index Scan on t_idx
1768
+ Index Cond: (v @@ '"array" && [2, 3]'::jsquery)
1769
+ (6 rows)
1770
+
1771
+ explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]' order by v;
1772
+ QUERY PLAN
1773
+ ---------------------------------------------------------------
1774
+ Sort
1775
+ Sort Key: v
1776
+ -> Bitmap Heap Scan on test_jsquery
1777
+ Recheck Cond: (v @@ '"array" @> [2, 3]'::jsquery)
1778
+ -> Bitmap Index Scan on t_idx
1779
+ Index Cond: (v @@ '"array" @> [2, 3]'::jsquery)
1780
+ (6 rows)
1781
+
1782
+ select v from test_jsquery where v @@ 'array <@ [2,3]' order by v;
1783
+ v
1784
+ -------------------
1785
+ {"array": [2]}
1786
+ {"array": [2, 3]}
1787
+ (2 rows)
1788
+
1789
+ select v from test_jsquery where v @@ 'array && [2,3]' order by v;
1790
+ v
1791
+ ----------------------
1792
+ {"array": [2]}
1793
+ {"array": [2, 3]}
1794
+ {"array": [1, 2, 3]}
1795
+ {"array": [2, 3, 4]}
1796
+ {"array": [3, 4, 5]}
1797
+ (5 rows)
1798
+
1799
+ select v from test_jsquery where v @@ 'array @> [2,3]' order by v;
1800
+ v
1801
+ ----------------------
1802
+ {"array": [2, 3]}
1803
+ {"array": [1, 2, 3]}
1804
+ {"array": [2, 3, 4]}
1805
+ (3 rows)
1806
+
1660
1807
RESET enable_seqscan;
0 commit comments