-- An IN list of the keys of a scope and an equality on one of them (the planner keeps both) are one test of the constants both hold: the scan tests a unit and a -- buffered row against that one constant, and prices it so. The answers are the heap's, with the equality in the list and out of it. CREATE EXTENSION pg_sift; SET max_parallel_workers_per_gather = 0; SET client_min_messages = warning; CREATE TABLE ev (id int PRIMARY KEY, k int NOT NULL, ts date NOT NULL, note text, pad text DEFAULT repeat('x', 100)); INSERT INTO ev (id, k, ts, note) SELECT g, 1 + (g * 7919) % 2000, date '2025-01-01' + g % 300, CASE WHEN g % 5 = 0 THEN NULL ELSE 'n' || g % 50 END FROM generate_series(1, 100000) g; CREATE INDEX ev_i ON ev USING sift_col (id, k, ts, note) WITH (key_cut = 'k', track_changes = 'off'); VACUUM (FREEZE, ANALYZE) ev; -- rows that are only in the write buffer INSERT INTO ev (id, k, ts, note) SELECT g, 1 + (g * 7919) % 2000, date '2025-01-01' + g % 300, 'n' || g % 50 FROM generate_series(100001, 110000) g; CREATE FUNCTION scope_list(n int) RETURNS text LANGUAGE sql AS $$ SELECT string_agg((1 + g * 6)::text, ',') FROM generate_series(0, n - 1) g $$; -- the rows of one shape by the column index's bitmap scan and by the heap CREATE FUNCTION rows_of(w text, scan boolean) RETURNS bigint[] LANGUAGE plpgsql AS $$ DECLARE r bigint[]; BEGIN IF scan THEN SET LOCAL sift.enable_col_scan = on; SET LOCAL enable_seqscan = off; SET LOCAL enable_indexscan = off; SET LOCAL enable_indexonlyscan = off; ELSE SET LOCAL enable_indexscan = off; SET LOCAL enable_bitmapscan = off; SET LOCAL enable_indexonlyscan = off; END IF; EXECUTE format('SELECT coalesce(array_agg(id ORDER BY id), ''{}'') FROM ev WHERE %s', w) INTO r; RETURN r; END $$; -- the blocks of the bitmap index scan, and the estimated cost of the plan CREATE FUNCTION index_blocks(w text) RETURNS int LANGUAGE plpgsql AS $$ DECLARE l text; n int; BEGIN SET LOCAL sift.enable_col_scan = on; SET LOCAL enable_seqscan = off; SET LOCAL enable_indexscan = off; SET LOCAL enable_indexonlyscan = off; FOR l IN EXECUTE format('EXPLAIN (ANALYZE, BUFFERS, COSTS OFF, TIMING OFF, SUMMARY OFF) SELECT id FROM ev WHERE %s', w) LOOP IF l ~ 'Bitmap Index Scan on ev_i' THEN n := 0; END IF; IF n IS NOT NULL AND l ~ '^ +Buffers: shared' THEN n := coalesce(substring(l from 'hit=(\d+)')::int, 0) + coalesce(substring(l from 'read=(\d+)')::int, 0); EXIT; END IF; END LOOP; RETURN n; END $$; CREATE FUNCTION plan_cost(w text) RETURNS float8 LANGUAGE plpgsql AS $$ DECLARE l text; c float8; BEGIN SET LOCAL sift.enable_col_scan = on; SET LOCAL enable_seqscan = off; SET LOCAL enable_indexscan = off; SET LOCAL enable_indexonlyscan = off; FOR l IN EXECUTE format('EXPLAIN SELECT id FROM ev WHERE %s', w) LOOP IF l ~ 'Bitmap Index Scan on ev_i' THEN c := substring(l from '\.\.([0-9.]+) rows')::float8; END IF; END LOOP; RETURN c; END $$; CREATE TABLE ev_q (n serial, w text); SELECT format($f$INSERT INTO ev_q (w) VALUES ('k = ANY (''{%1$s}'') AND k = 7'), ('k = ANY (''{%1$s}'') AND k = 8'), ('k = ANY (''{%1$s}'') AND k = 601 AND ts > ''2025-06-01'''), ('k = ANY (''{%1$s}'') AND k IN (7, 13, 8, 19, 1000)'), ('k = ANY (''{%1$s}'') AND note IS NOT NULL AND k = 1201'), ('k = 13 AND k = ANY (''{%1$s}'')'), ('k = ANY (''{%1$s}'') AND k = ANY (''{%2$s}'')')$f$, scope_list(300), scope_list(1000)) \gexec INSERT INTO ev_q (w) VALUES ('k = ANY (''{1,7,13,19,25,31,37,43,49,55,61,67,73,79,85,91,97,103,109,115,121,127,133,139,145,151,157,163,169,175,181,187,193,199,205,211,217,223,229,235,241,247,253,259,265,271,277,283,289,295,301,307,313,319,325,331,337,343,349,355,361,367,373,379,385,391,397,403,409,415,421,427,433,439,445,451,457,463,469,475,481,487,493,499,505,511,517,523,529,535,541,547,553,559,565,571,577,583,589,595,601,607,613,619,625,631,637,643,649,655,661,667,673,679,685,691,697,703,709,715,721,727,733,739,745,751,757,763,769,775,781,787,793,799,805,811,817,823,829,835,841,847,853,859,865,871,877,883,889,895,901,907,913,919,925,931,937,943,949,955,961,967,973,979,985,991,997,1003,1009,1015,1021,1027,1033,1039,1045,1051,1057,1063,1069,1075,1081,1087,1093,1099,1105,1111,1117,1123,1129,1135,1141,1147,1153,1159,1165,1171,1177,1183,1189,1195,1201,1207,1213,1219,1225,1231,1237,1243,1249,1255,1261,1267,1273,1279,1285,1291,1297,1303,1309,1315,1321,1327,1333,1339,1345,1351,1357,1363,1369,1375,1381,1387,1393,1399,1405,1411,1417,1423,1429,1435,1441,1447,1453,1459,1465,1471,1477,1483,1489,1495,1501,1507,1513,1519,1525,1531,1537,1543,1549,1555,1561,1567,1573,1579,1585,1591,1597,1603,1609,1615,1621,1627,1633,1639,1645,1651,1657,1663,1669,1675,1681,1687,1693,1699,1705,1711,1717,1723,1729,1735,1741,1747,1753,1759,1765,1771,1777,1783,1789,1795}'') AND k = 7'), ('k = ANY (''{1,7,13,19,25,31,37,43,49,55,61,67,73,79,85,91,97,103,109,115,121,127,133,139,145,151,157,163,169,175,181,187,193,199,205,211,217,223,229,235,241,247,253,259,265,271,277,283,289,295,301,307,313,319,325,331,337,343,349,355,361,367,373,379,385,391,397,403,409,415,421,427,433,439,445,451,457,463,469,475,481,487,493,499,505,511,517,523,529,535,541,547,553,559,565,571,577,583,589,595,601,607,613,619,625,631,637,643,649,655,661,667,673,679,685,691,697,703,709,715,721,727,733,739,745,751,757,763,769,775,781,787,793,799,805,811,817,823,829,835,841,847,853,859,865,871,877,883,889,895,901,907,913,919,925,931,937,943,949,955,961,967,973,979,985,991,997,1003,1009,1015,1021,1027,1033,1039,1045,1051,1057,1063,1069,1075,1081,1087,1093,1099,1105,1111,1117,1123,1129,1135,1141,1147,1153,1159,1165,1171,1177,1183,1189,1195,1201,1207,1213,1219,1225,1231,1237,1243,1249,1255,1261,1267,1273,1279,1285,1291,1297,1303,1309,1315,1321,1327,1333,1339,1345,1351,1357,1363,1369,1375,1381,1387,1393,1399,1405,1411,1417,1423,1429,1435,1441,1447,1453,1459,1465,1471,1477,1483,1489,1495,1501,1507,1513,1519,1525,1531,1537,1543,1549,1555,1561,1567,1573,1579,1585,1591,1597,1603,1609,1615,1621,1627,1633,1639,1645,1651,1657,1663,1669,1675,1681,1687,1693,1699,1705,1711,1717,1723,1729,1735,1741,1747,1753,1759,1765,1771,1777,1783,1789,1795}'') AND k = 8'), ('k = ANY (''{1,7,13,19,25,31,37,43,49,55,61,67,73,79,85,91,97,103,109,115,121,127,133,139,145,151,157,163,169,175,181,187,193,199,205,211,217,223,229,235,241,247,253,259,265,271,277,283,289,295,301,307,313,319,325,331,337,343,349,355,361,367,373,379,385,391,397,403,409,415,421,427,433,439,445,451,457,463,469,475,481,487,493,499,505,511,517,523,529,535,541,547,553,559,565,571,577,583,589,595,601,607,613,619,625,631,637,643,649,655,661,667,673,679,685,691,697,703,709,715,721,727,733,739,745,751,757,763,769,775,781,787,793,799,805,811,817,823,829,835,841,847,853,859,865,871,877,883,889,895,901,907,913,919,925,931,937,943,949,955,961,967,973,979,985,991,997,1003,1009,1015,1021,1027,1033,1039,1045,1051,1057,1063,1069,1075,1081,1087,1093,1099,1105,1111,1117,1123,1129,1135,1141,1147,1153,1159,1165,1171,1177,1183,1189,1195,1201,1207,1213,1219,1225,1231,1237,1243,1249,1255,1261,1267,1273,1279,1285,1291,1297,1303,1309,1315,1321,1327,1333,1339,1345,1351,1357,1363,1369,1375,1381,1387,1393,1399,1405,1411,1417,1423,1429,1435,1441,1447,1453,1459,1465,1471,1477,1483,1489,1495,1501,1507,1513,1519,1525,1531,1537,1543,1549,1555,1561,1567,1573,1579,1585,1591,1597,1603,1609,1615,1621,1627,1633,1639,1645,1651,1657,1663,1669,1675,1681,1687,1693,1699,1705,1711,1717,1723,1729,1735,1741,1747,1753,1759,1765,1771,1777,1783,1789,1795}'') AND k = 601 AND ts > ''2025-06-01'''), ('k = ANY (''{1,7,13,19,25,31,37,43,49,55,61,67,73,79,85,91,97,103,109,115,121,127,133,139,145,151,157,163,169,175,181,187,193,199,205,211,217,223,229,235,241,247,253,259,265,271,277,283,289,295,301,307,313,319,325,331,337,343,349,355,361,367,373,379,385,391,397,403,409,415,421,427,433,439,445,451,457,463,469,475,481,487,493,499,505,511,517,523,529,535,541,547,553,559,565,571,577,583,589,595,601,607,613,619,625,631,637,643,649,655,661,667,673,679,685,691,697,703,709,715,721,727,733,739,745,751,757,763,769,775,781,787,793,799,805,811,817,823,829,835,841,847,853,859,865,871,877,883,889,895,901,907,913,919,925,931,937,943,949,955,961,967,973,979,985,991,997,1003,1009,1015,1021,1027,1033,1039,1045,1051,1057,1063,1069,1075,1081,1087,1093,1099,1105,1111,1117,1123,1129,1135,1141,1147,1153,1159,1165,1171,1177,1183,1189,1195,1201,1207,1213,1219,1225,1231,1237,1243,1249,1255,1261,1267,1273,1279,1285,1291,1297,1303,1309,1315,1321,1327,1333,1339,1345,1351,1357,1363,1369,1375,1381,1387,1393,1399,1405,1411,1417,1423,1429,1435,1441,1447,1453,1459,1465,1471,1477,1483,1489,1495,1501,1507,1513,1519,1525,1531,1537,1543,1549,1555,1561,1567,1573,1579,1585,1591,1597,1603,1609,1615,1621,1627,1633,1639,1645,1651,1657,1663,1669,1675,1681,1687,1693,1699,1705,1711,1717,1723,1729,1735,1741,1747,1753,1759,1765,1771,1777,1783,1789,1795}'') AND k IN (7, 13, 8, 19, 1000)'), ('k = ANY (''{1,7,13,19,25,31,37,43,49,55,61,67,73,79,85,91,97,103,109,115,121,127,133,139,145,151,157,163,169,175,181,187,193,199,205,211,217,223,229,235,241,247,253,259,265,271,277,283,289,295,301,307,313,319,325,331,337,343,349,355,361,367,373,379,385,391,397,403,409,415,421,427,433,439,445,451,457,463,469,475,481,487,493,499,505,511,517,523,529,535,541,547,553,559,565,571,577,583,589,595,601,607,613,619,625,631,637,643,649,655,661,667,673,679,685,691,697,703,709,715,721,727,733,739,745,751,757,763,769,775,781,787,793,799,805,811,817,823,829,835,841,847,853,859,865,871,877,883,889,895,901,907,913,919,925,931,937,943,949,955,961,967,973,979,985,991,997,1003,1009,1015,1021,1027,1033,1039,1045,1051,1057,1063,1069,1075,1081,1087,1093,1099,1105,1111,1117,1123,1129,1135,1141,1147,1153,1159,1165,1171,1177,1183,1189,1195,1201,1207,1213,1219,1225,1231,1237,1243,1249,1255,1261,1267,1273,1279,1285,1291,1297,1303,1309,1315,1321,1327,1333,1339,1345,1351,1357,1363,1369,1375,1381,1387,1393,1399,1405,1411,1417,1423,1429,1435,1441,1447,1453,1459,1465,1471,1477,1483,1489,1495,1501,1507,1513,1519,1525,1531,1537,1543,1549,1555,1561,1567,1573,1579,1585,1591,1597,1603,1609,1615,1621,1627,1633,1639,1645,1651,1657,1663,1669,1675,1681,1687,1693,1699,1705,1711,1717,1723,1729,1735,1741,1747,1753,1759,1765,1771,1777,1783,1789,1795}'') AND note IS NOT NULL AND k = 1201'), ('k = 13 AND k = ANY (''{1,7,13,19,25,31,37,43,49,55,61,67,73,79,85,91,97,103,109,115,121,127,133,139,145,151,157,163,169,175,181,187,193,199,205,211,217,223,229,235,241,247,253,259,265,271,277,283,289,295,301,307,313,319,325,331,337,343,349,355,361,367,373,379,385,391,397,403,409,415,421,427,433,439,445,451,457,463,469,475,481,487,493,499,505,511,517,523,529,535,541,547,553,559,565,571,577,583,589,595,601,607,613,619,625,631,637,643,649,655,661,667,673,679,685,691,697,703,709,715,721,727,733,739,745,751,757,763,769,775,781,787,793,799,805,811,817,823,829,835,841,847,853,859,865,871,877,883,889,895,901,907,913,919,925,931,937,943,949,955,961,967,973,979,985,991,997,1003,1009,1015,1021,1027,1033,1039,1045,1051,1057,1063,1069,1075,1081,1087,1093,1099,1105,1111,1117,1123,1129,1135,1141,1147,1153,1159,1165,1171,1177,1183,1189,1195,1201,1207,1213,1219,1225,1231,1237,1243,1249,1255,1261,1267,1273,1279,1285,1291,1297,1303,1309,1315,1321,1327,1333,1339,1345,1351,1357,1363,1369,1375,1381,1387,1393,1399,1405,1411,1417,1423,1429,1435,1441,1447,1453,1459,1465,1471,1477,1483,1489,1495,1501,1507,1513,1519,1525,1531,1537,1543,1549,1555,1561,1567,1573,1579,1585,1591,1597,1603,1609,1615,1621,1627,1633,1639,1645,1651,1657,1663,1669,1675,1681,1687,1693,1699,1705,1711,1717,1723,1729,1735,1741,1747,1753,1759,1765,1771,1777,1783,1789,1795}'')'), ('k = ANY (''{1,7,13,19,25,31,37,43,49,55,61,67,73,79,85,91,97,103,109,115,121,127,133,139,145,151,157,163,169,175,181,187,193,199,205,211,217,223,229,235,241,247,253,259,265,271,277,283,289,295,301,307,313,319,325,331,337,343,349,355,361,367,373,379,385,391,397,403,409,415,421,427,433,439,445,451,457,463,469,475,481,487,493,499,505,511,517,523,529,535,541,547,553,559,565,571,577,583,589,595,601,607,613,619,625,631,637,643,649,655,661,667,673,679,685,691,697,703,709,715,721,727,733,739,745,751,757,763,769,775,781,787,793,799,805,811,817,823,829,835,841,847,853,859,865,871,877,883,889,895,901,907,913,919,925,931,937,943,949,955,961,967,973,979,985,991,997,1003,1009,1015,1021,1027,1033,1039,1045,1051,1057,1063,1069,1075,1081,1087,1093,1099,1105,1111,1117,1123,1129,1135,1141,1147,1153,1159,1165,1171,1177,1183,1189,1195,1201,1207,1213,1219,1225,1231,1237,1243,1249,1255,1261,1267,1273,1279,1285,1291,1297,1303,1309,1315,1321,1327,1333,1339,1345,1351,1357,1363,1369,1375,1381,1387,1393,1399,1405,1411,1417,1423,1429,1435,1441,1447,1453,1459,1465,1471,1477,1483,1489,1495,1501,1507,1513,1519,1525,1531,1537,1543,1549,1555,1561,1567,1573,1579,1585,1591,1597,1603,1609,1615,1621,1627,1633,1639,1645,1651,1657,1663,1669,1675,1681,1687,1693,1699,1705,1711,1717,1723,1729,1735,1741,1747,1753,1759,1765,1771,1777,1783,1789,1795}'') AND k = ANY (''{1,7,13,19,25,31,37,43,49,55,61,67,73,79,85,91,97,103,109,115,121,127,133,139,145,151,157,163,169,175,181,187,193,199,205,211,217,223,229,235,241,247,253,259,265,271,277,283,289,295,301,307,313,319,325,331,337,343,349,355,361,367,373,379,385,391,397,403,409,415,421,427,433,439,445,451,457,463,469,475,481,487,493,499,505,511,517,523,529,535,541,547,553,559,565,571,577,583,589,595,601,607,613,619,625,631,637,643,649,655,661,667,673,679,685,691,697,703,709,715,721,727,733,739,745,751,757,763,769,775,781,787,793,799,805,811,817,823,829,835,841,847,853,859,865,871,877,883,889,895,901,907,913,919,925,931,937,943,949,955,961,967,973,979,985,991,997,1003,1009,1015,1021,1027,1033,1039,1045,1051,1057,1063,1069,1075,1081,1087,1093,1099,1105,1111,1117,1123,1129,1135,1141,1147,1153,1159,1165,1171,1177,1183,1189,1195,1201,1207,1213,1219,1225,1231,1237,1243,1249,1255,1261,1267,1273,1279,1285,1291,1297,1303,1309,1315,1321,1327,1333,1339,1345,1351,1357,1363,1369,1375,1381,1387,1393,1399,1405,1411,1417,1423,1429,1435,1441,1447,1453,1459,1465,1471,1477,1483,1489,1495,1501,1507,1513,1519,1525,1531,1537,1543,1549,1555,1561,1567,1573,1579,1585,1591,1597,1603,1609,1615,1621,1627,1633,1639,1645,1651,1657,1663,1669,1675,1681,1687,1693,1699,1705,1711,1717,1723,1729,1735,1741,1747,1753,1759,1765,1771,1777,1783,1789,1795,1801,1807,1813,1819,1825,1831,1837,1843,1849,1855,1861,1867,1873,1879,1885,1891,1897,1903,1909,1915,1921,1927,1933,1939,1945,1951,1957,1963,1969,1975,1981,1987,1993,1999,2005,2011,2017,2023,2029,2035,2041,2047,2053,2059,2065,2071,2077,2083,2089,2095,2101,2107,2113,2119,2125,2131,2137,2143,2149,2155,2161,2167,2173,2179,2185,2191,2197,2203,2209,2215,2221,2227,2233,2239,2245,2251,2257,2263,2269,2275,2281,2287,2293,2299,2305,2311,2317,2323,2329,2335,2341,2347,2353,2359,2365,2371,2377,2383,2389,2395,2401,2407,2413,2419,2425,2431,2437,2443,2449,2455,2461,2467,2473,2479,2485,2491,2497,2503,2509,2515,2521,2527,2533,2539,2545,2551,2557,2563,2569,2575,2581,2587,2593,2599,2605,2611,2617,2623,2629,2635,2641,2647,2653,2659,2665,2671,2677,2683,2689,2695,2701,2707,2713,2719,2725,2731,2737,2743,2749,2755,2761,2767,2773,2779,2785,2791,2797,2803,2809,2815,2821,2827,2833,2839,2845,2851,2857,2863,2869,2875,2881,2887,2893,2899,2905,2911,2917,2923,2929,2935,2941,2947,2953,2959,2965,2971,2977,2983,2989,2995,3001,3007,3013,3019,3025,3031,3037,3043,3049,3055,3061,3067,3073,3079,3085,3091,3097,3103,3109,3115,3121,3127,3133,3139,3145,3151,3157,3163,3169,3175,3181,3187,3193,3199,3205,3211,3217,3223,3229,3235,3241,3247,3253,3259,3265,3271,3277,3283,3289,3295,3301,3307,3313,3319,3325,3331,3337,3343,3349,3355,3361,3367,3373,3379,3385,3391,3397,3403,3409,3415,3421,3427,3433,3439,3445,3451,3457,3463,3469,3475,3481,3487,3493,3499,3505,3511,3517,3523,3529,3535,3541,3547,3553,3559,3565,3571,3577,3583,3589,3595,3601,3607,3613,3619,3625,3631,3637,3643,3649,3655,3661,3667,3673,3679,3685,3691,3697,3703,3709,3715,3721,3727,3733,3739,3745,3751,3757,3763,3769,3775,3781,3787,3793,3799,3805,3811,3817,3823,3829,3835,3841,3847,3853,3859,3865,3871,3877,3883,3889,3895,3901,3907,3913,3919,3925,3931,3937,3943,3949,3955,3961,3967,3973,3979,3985,3991,3997,4003,4009,4015,4021,4027,4033,4039,4045,4051,4057,4063,4069,4075,4081,4087,4093,4099,4105,4111,4117,4123,4129,4135,4141,4147,4153,4159,4165,4171,4177,4183,4189,4195,4201,4207,4213,4219,4225,4231,4237,4243,4249,4255,4261,4267,4273,4279,4285,4291,4297,4303,4309,4315,4321,4327,4333,4339,4345,4351,4357,4363,4369,4375,4381,4387,4393,4399,4405,4411,4417,4423,4429,4435,4441,4447,4453,4459,4465,4471,4477,4483,4489,4495,4501,4507,4513,4519,4525,4531,4537,4543,4549,4555,4561,4567,4573,4579,4585,4591,4597,4603,4609,4615,4621,4627,4633,4639,4645,4651,4657,4663,4669,4675,4681,4687,4693,4699,4705,4711,4717,4723,4729,4735,4741,4747,4753,4759,4765,4771,4777,4783,4789,4795,4801,4807,4813,4819,4825,4831,4837,4843,4849,4855,4861,4867,4873,4879,4885,4891,4897,4903,4909,4915,4921,4927,4933,4939,4945,4951,4957,4963,4969,4975,4981,4987,4993,4999,5005,5011,5017,5023,5029,5035,5041,5047,5053,5059,5065,5071,5077,5083,5089,5095,5101,5107,5113,5119,5125,5131,5137,5143,5149,5155,5161,5167,5173,5179,5185,5191,5197,5203,5209,5215,5221,5227,5233,5239,5245,5251,5257,5263,5269,5275,5281,5287,5293,5299,5305,5311,5317,5323,5329,5335,5341,5347,5353,5359,5365,5371,5377,5383,5389,5395,5401,5407,5413,5419,5425,5431,5437,5443,5449,5455,5461,5467,5473,5479,5485,5491,5497,5503,5509,5515,5521,5527,5533,5539,5545,5551,5557,5563,5569,5575,5581,5587,5593,5599,5605,5611,5617,5623,5629,5635,5641,5647,5653,5659,5665,5671,5677,5683,5689,5695,5701,5707,5713,5719,5725,5731,5737,5743,5749,5755,5761,5767,5773,5779,5785,5791,5797,5803,5809,5815,5821,5827,5833,5839,5845,5851,5857,5863,5869,5875,5881,5887,5893,5899,5905,5911,5917,5923,5929,5935,5941,5947,5953,5959,5965,5971,5977,5983,5989,5995}'')') SELECT count(*) AS shapes FROM ev_q; shapes -------- 7 (1 row) SELECT n, w FROM ev_q WHERE rows_of(w, true) <> rows_of(w, false) ORDER BY n; n | w ---+--- (0 rows) SELECT n, cardinality(rows_of(w, false)) > 0 AS has_rows FROM ev_q ORDER BY n; n | has_rows ---+---------- 1 | t 2 | f 3 | t 4 | t 5 | t 6 | t 7 | t (7 rows) -- the equality is out of the list: nothing can match, and the scan reads no unit SELECT index_blocks(format('k = ANY (''{%s}'') AND k = 8', scope_list(300))) <= 8 AS unsatisfiable_reads_nothing; unsatisfiable_reads_nothing ----------------------------- t (1 row) -- the list costs no more than its equality SELECT plan_cost(format('k = ANY (''{%s}'') AND k = 7', scope_list(300))) <= 1.05 * plan_cost('k = 7') AS list_adds_no_cost; list_adds_no_cost ------------------- t (1 row) DROP TABLE ev, ev_q CASCADE; DROP FUNCTION scope_list(int), rows_of(text, boolean), index_blocks(text), plan_cost(text); DROP EXTENSION pg_sift;