@@ -1184,7 +1184,10 @@ SELECT gin_debug_query_path_value('x @> [1,2,3]');
11841184SELECT gin_debug_query_path_value('x <@ [1,2,3]');
11851185 gin_debug_query_path_value
11861186----------------------------
1187- NULL +
1187+ OR +
1188+ x.# = 1 , entry 0 +
1189+ x.# = 2 , entry 1 +
1190+ x.# = 3 , entry 2 +
11881191
11891192(1 row)
11901193
@@ -1293,7 +1296,10 @@ SELECT gin_debug_query_value_path('x @> [1,2,3]');
12931296SELECT gin_debug_query_value_path('x <@ [1,2,3]');
12941297 gin_debug_query_value_path
12951298----------------------------
1296- NULL +
1299+ OR +
1300+ x.# = 1 , entry 0 +
1301+ x.# = 2 , entry 1 +
1302+ x.# = 3 , entry 2 +
12971303
12981304(1 row)
12991305
@@ -1438,6 +1444,31 @@ select count(*) from test_jsquery where v @@ 'product_group = false';
14381444 1
14391445(1 row)
14401446
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+
14411472create index t_idx on test_jsquery using gin (v jsonb_value_path_ops);
14421473set enable_seqscan = off;
14431474explain (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';
15471578 1
15481579(1 row)
15491580
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+
15501639drop index t_idx;
15511640create index t_idx on test_jsquery using gin (v jsonb_path_value_ops);
15521641set enable_seqscan = off;
@@ -1657,4 +1746,62 @@ select count(*) from test_jsquery where v @@ 'product_group = false';
16571746 1
16581747(1 row)
16591748
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+
16601807RESET enable_seqscan;