We have finally been able to find a reproducible test case that we can share. The schema, query, 15.13, and 17.5 plans are included in full below. The performance difference is due to different traversals of the zsf table: create table zsf( id bigint primary key, cid bigint not null, fpi bigint not null, unique (id, fpi, cid) ); create index on zsf(cid) ; The query reads from this table with a join using the "id" column and a list of ~500 literals for the "cid" column. The "fpi" column is not referenced. The 15.13 plan traverses zsf with an index scan on "id" and a filter on "cid". The 17.5 plan uses and index-only scan keyed on "id" and "cid" and is significantly slower. However, if we create an index on "(id, cid)", 17.5 consistently runs slightly faster. The other tables in the query serve to amplify the effect so that the run time difference sticks out way above the noise. The effect can be more simply reproduced with just select count(*) from zsf where id = 12342 and cid in (long_constant_list) where 15.13 is consistently ~55ms and 17.5 is consistently ~75ms. We have an approximately 675K dump of the test DB used to generate the query plans below, and we can provide a copy if anyone needs it to investigate further. Thanks for your help! -- todd The test schema is create table zps ( id bigint primary key, sid bigint not null, pid bigint not null, col1 bigint, col2 varchar(255) not null, unique(sid, col1), unique(pid, sid) ) ; create table zs( id bigint primary key, col18 bigint not null default 42 ); create table zse(id bigint, sid bigint); alter table zse add primary key (id) ; create index on zse(sid) ; create table zsd(id bigint, sei bigint, dti bigint); alter table zsd add primary key (id) ; create index on zsd(dti) ; create index on zsd(sei) ; create table zsdo(sdi bigint, sfi bigint); create index on zsdo(sdi) ; create index on zsdo(sfi) ; create table zsf( id bigint primary key, cid bigint not null, fpi bigint not null, unique (id, fpi, cid) ); create index on zsf(cid) ; create table zdt(id bigint); alter table zdt add primary key (id) ; The query is explain analyze select * FROM zps ps JOIN zs s ON ps.sid = s.id JOIN zse se ON s.id = se.sid JOIN zsd sd ON sd.sei = se.id JOIN zsdo sdo ON sd.id = sdo.sdi JOIN zsf sf ON sdo.sfi = sf.id JOIN zdt dt ON dt.id = sd.dti WHERE ps.pid in (10075) AND s.id IN (10040,10002,10003,10004,10005,10006,10007,10008,10009,10010,10011,10012,10013,10014,10015,10016,10017,10018,10019,10020,10021,10022,10023,10024,10025,10026,10027,10028,10029,10030,10031,10032,10001,10033,10034,10035,10036,10037,10038,10039,10041,10042,10043,10044,10045,10046,10047,10048,10049,10050,10051,10052,10053,10054,10055,10056,10057,10058,10059,10060,10061,10062,10063,10064,10065,10066,10067,10068,10069,10070,10071,10072,10073,10074,10075,10076,10077,10078,10079,10080) AND sf.cid IN (1,10229,10230,10231,10232,10233,10234,10235,10236,10237,10238,10239,10240,10241,10242,10243,10244,10245,10246,10247,10248,10249,10250,10251,10252,10253,10254,10255,10256,10257,10258,10259,10260,10261,10262,10263,10264,10265,10266,10267,10268,10269,10270,10271,10272,10273,10274,10275,10276,10277,10278,10279,10280,10281,10282,10283,10284,10285,10286,10287,10288,10289,10290,10291,10292,10293,10294,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10308,10309,10310,10311,10312,10313,10314,10315,10316,10317,10318,10319,10320,10321,10322,10323,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334,10335,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10347,10348,10349,10350,10351,10352,10353,10354,10355,10356,10357,10358,10359,10360,10361,10362,10363,10364,10365,10366,10367,10368,10369,10370,10371,10372,10373,10374,10375,10376,10377,10378,10379,10380,10381,10382,10383,10384,10385,10386,10387,10388,10389,10390,10391,10392,10393,10394,10395,10396,10397,10398,10399,10400,10401,10402,10403,10404,10405,10406,10407,10408,10409,10410,10411,10412,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424,10425,10426,10427,10428,10429,10430,10431,10432,10433,10434,10435,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10004,10005,10007,10008,10002,10010,10011,10012,10055,10056,10130,10174,10182,10183,10184,10185,10186,10187,10188,10189,10190,10916,10923,10924,10925,10926,10927,10928,10929,10930,10931,10932,10933,10934,10935,10936,10937,10938,10939,10940,10941,10942,10943,10944,10945,10946,10947,10948,10949,10950,10951,10952,10953,10954,10955,10956,10957,10958,10959,10960,10961,10962,10963,10964,10965,10966,10967,10968,10969,10970,10971,10972,10973,10974,10975,10976,10977,10978,10979,10980,10981,10982,10983,10984,10985,10986,10987,10988,10989,10990,10991,10992,10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008,11009,11010,11011,11012,11013,11014,11015,11016,11017,11018,11019,11020,11021,11022,11023,11024,11025,11026,11027,11028,11029,11030,11031,11032,11033,11034,11035,11036,11037,11038,11039,11040,11041,11042,11043,11044,11045,11046,11047,11048,11049,11050,11051,11052,11053,11054,11055,11056,11057,11058,11059,11060,11061,11062,11063,11064,11065,11066,11067,11068,11069,11070,11071,11072,11073,11074,11075,11076,11077,11078,11079,11080,11081,11082,11083,11084,11085,11086,11087,11088,11089,11090,11091,11092,11093,11094,11095,11096,11097,11098,11099,11100,11101,11102,11103,11104,11105,11106,11107,11108,11109,11110,11111,11112,11113,11114,11115,11116,11117,11118,11119,11120,11121,11122,11123,11124,11125,11126,11127,11128,11129,11130,11131,11132,11133,11134,11135,11136,11137,11138,11139,11140,11141,11142,11143,11144,11145,11146,11147,11148,11149); The plan on PG 15.13 is Nested Loop (cost=23.40..1898.22 rows=127 width=281) (actual time=0.117..95.363 rows=47089 loops=1) -> Nested Loop (cost=21.91..1687.85 rows=139 width=257) (actual time=0.098..53.811 rows=47089 loops=1) -> Hash Join (cost=21.62..50.38 rows=105 width=241) (actual time=0.084..15.648 rows=35944 loops=1) Hash Cond: (sd.dti = dt.id) -> Nested Loop (cost=19.49..47.13 rows=421 width=233) (actual time=0.067..9.964 rows=35944 loops=1) -> Nested Loop (cost=19.20..30.68 rows=1 width=209) (actual time=0.053..0.063 rows=2 loops=1) Join Filter: (ps.sid = se.sid) -> Hash Join (cost=19.05..30.46 rows=1 width=193) (actual time=0.045..0.052 rows=1 loops=1) Hash Cond: (s.id = ps.sid) -> Bitmap Heap Scan on zs s (cost=15.42..26.62 rows=80 width=16) (actual time=0.025..0.032 rows=80 loops=1) Recheck Cond: (id = ANY ('{...}'::bigint[])) Heap Blocks: exact=1 -> Bitmap Index Scan on zs_pkey (cost=0.00..15.20 rows=80 width=0) (actual time=0.021..0.022 rows=80 loops=1) Index Cond: (id = ANY ('{10040,10002,10003,10004,10005,10006,10007,10008,10009,10010,10011,10012,10013,10014,10015,10016,10017,10018,10019,10020,10021,10022,10023,10024,10025,10026,10027,10028,10029,10030,10031,10032,10001,10033,10034,10035,10036,10037,10038,10039,10041,10042,10043,10044,10045,10046,10047,10048,10049,10050,10051,10052,10053,10054,10055,10056,10057,10058,10059,10060,10061,10062,10063,10064,10065,10066,10067,10068,10069,10070,10071,10072,10073,10074,10075,10076,10077,10078,10079,10080}'::bigint[])) -> Hash (cost=3.61..3.61 rows=2 width=177) (actual time=0.009..0.011 rows=1 loops=1) Buckets: 1024 Batches: 1 Memory Usage: 9kB -> Bitmap Heap Scan on zps ps (cost=1.36..3.61 rows=2 width=177) (actual time=0.009..0.010 rows=1 loops=1) Recheck Cond: (pid = 10075) Heap Blocks: exact=1 -> Bitmap Index Scan on zps_pid_sid_key (cost=0.00..1.36 rows=2 width=0) (actual time=0.005..0.005 rows=1 loops=1) Index Cond: (pid = 10075) -> Index Scan using zse_sid_idx on zse se (cost=0.14..0.21 rows=1 width=16) (actual time=0.007..0.008 rows=2 loops=1) Index Cond: (sid = s.id) -> Index Scan using zsd_sei_idx on zsd sd (cost=0.29..12.23 rows=421 width=24) (actual time=0.006..3.255 rows=17972 loops=2) Index Cond: (sei = se.id) -> Hash (cost=1.50..1.50 rows=50 width=8) (actual time=0.013..0.013 rows=50 loops=1) Buckets: 1024 Batches: 1 Memory Usage: 10kB -> Seq Scan on zdt dt (cost=0.00..1.50 rows=50 width=8) (actual time=0.006..0.008 rows=50 loops=1) -> Index Scan using zsdo_sdi_idx on zsdo sdo (cost=0.29..10.03 rows=556 width=16) (actual time=0.001..0.001 rows=1 loops=35944) Index Cond: (sdi = sd.id) -> Index Scan using zsf_pkey on zsf sf (cost=1.49..1.51 rows=1 width=24) (actual time=0.001..0.001 rows=1 loops=47089) Index Cond: (id = sdo.sfi) Filter: (cid = ANY ('{...}'::bigint[])) Planning Time: 1.110 ms Execution Time: 96.732 ms The plan on PG 17.5 is Nested Loop (cost=3.29..902.10 rows=1356 width=143) (actual time=0.223..1161.699 rows=47089 loops=1) -> Nested Loop (cost=3.00..464.90 rows=1391 width=119) (actual time=0.160..59.762 rows=47089 loops=1) -> Hash Join (cost=2.71..86.20 rows=1052 width=103) (actual time=0.133..17.091 rows=35944 loops=1) Hash Cond: (sd.dti = dt.id) -> Nested Loop (cost=0.58..81.08 rows=1052 width=95) (actual time=0.082..10.065 rows=35944 loops=1) -> Nested Loop (cost=0.29..4.87 rows=2 width=71) (actual time=0.045..0.052 rows=2 loops=1) Join Filter: (ps.sid = se.sid) -> Nested Loop (cost=0.14..4.62 rows=1 width=55) (actual time=0.026..0.029 rows=1 loops=1) -> Seq Scan on zps ps (cost=0.00..2.00 rows=1 width=39) (actual time=0.012..0.014 rows=1 loops=1) Filter: (pid = 10075) Rows Removed by Filter: 79 -> Index Scan using zs_pkey on zs s (cost=0.14..2.56 rows=1 width=16) (actual time=0.012..0.013 rows=1 loops=1) Index Cond: ((id = ps.sid) AND (id = ANY ('{...}'::bigint[]))) -> Index Scan using zse_sid_idx on zse se (cost=0.14..0.23 rows=2 width=16) (actual time=0.018..0.020 rows=2 loops=1) Index Cond: (sid = s.id) -> Index Scan using zsd_sei_idx on zsd sd (cost=0.29..26.08 rows=1202 width=24) (actual time=0.017..3.309 rows=17972 loops=2) Index Cond: (sei = se.id) -> Hash (cost=1.50..1.50 rows=50 width=8) (actual time=0.031..0.032 rows=50 loops=1) Buckets: 1024 Batches: 1 Memory Usage: 10kB -> Seq Scan on zdt dt (cost=0.00..1.50 rows=50 width=8) (actual time=0.021..0.024 rows=50 loops=1) -> Index Scan using zsdo_sdi_idx on zsdo sdo (cost=0.29..0.34 rows=2 width=16) (actual time=0.001..0.001 rows=1 loops=35944) Index Cond: (sdi = sd.id) -> Index Only Scan using zsf_id_fpi_cid_key on zsf sf (cost=0.29..0.31 rows=1 width=24) (actual time=0.023..0.023 rows=1 loops=47089) Index Cond: ((id = sdo.sfi) AND (cid = ANY ('{...}'::bigint[]))) Heap Fetches: 47089 Planning Time: 3.041 ms Execution Time: 1163.189 ms