Most of the cost is here:
-> Hash (cost=154514.79..154514.79 rows=63224 width=8) (actual time=116.328..116.328 rows=67260 loops=1) -> Bitmap Heap Scan on binarypackagerelease (cost=1770.43..154514.79 rows=63224 width=8) (actual time=25.402..88.795 rows=67260 loops=1) Recheck Cond: (binarypackagename = ANY ('{151425,151426,67843,67846,112519,151432,96654,112530,151427,175764,85790,85791,77217,77218,77219,77221,77222,77223,77224,81577,134905,151430,73520,71474,73526,73527,175544,100925,175553,160578,160579,88773,81144,104275,151431,88789,120023,86619,86620,67841,67937,67938,81768,84716,175763,119540,182134,182135,146424,146425,126586,67838,133717}'::integer[])) -> Bitmap Index Scan on binarypackagerelease_binarypackagename_key (cost=0.00..1754.62 rows=63224 width=0) (actual time=18.315..18.315 rows=67260 loops=1) Index Cond: (binarypackagename = ANY ('{151425,151426,67843,67846,112519,151432,96654,112530,151427,175764,85790,85791,77217,77218,77219,77221,77222,77223,77224,81577,134905,151430,73520,71474,73526,73527,175544,100925,175553,160578,160579,88773,81144,104275,151431,88789,120023,86619,86620,67841,67937,67938,81768,84716,175763,119540,182134,182135,146424,146425,126586,67838,133717}'::integer[]))
Most of the cost is here:
-> Hash (cost=154514. 79..154514. 79 rows=63224 width=8) (actual time=116. 328..116. 328 rows=67260 loops=1) lease (cost=1770. 43..154514. 79 rows=63224 width=8) (actual time=25.402..88.795 rows=67260 loops=1)
Recheck Cond: (binarypackagename = ANY ('{151425, 151426, 67843,67846, 112519, 151432, 96654,112530, 151427, 175764, 85790,85791, 77217,77218, 77219,77221, 77222,77223, 77224,81577, 134905, 151430, 73520,71474, 73526,73527, 175544, 100925, 175553, 160578, 160579, 88773,81144, 104275, 151431, 88789,120023, 86619,86620, 67841,67937, 67938,81768, 84716,175763, 119540, 182134, 182135, 146424, 146425, 126586, 67838,133717} '::integer[ ]))
-> Bitmap Index Scan on binarypackagere lease_binarypac kagename_ key (cost=0.00..1754.62 rows=63224 width=0) (actual time=18.315..18.315 rows=67260 loops=1)
Index Cond: (binarypackagename = ANY ('{151425, 151426, 67843,67846, 112519, 151432, 96654,112530, 151427, 175764, 85790,85791, 77217,77218, 77219,77221, 77222,77223, 77224,81577, 134905, 151430, 73520,71474, 73526,73527, 175544, 100925, 175553, 160578, 160579, 88773,81144, 104275, 151431, 88789,120023, 86619,86620, 67841,67937, 67938,81768, 84716,175763, 119540, 182134, 182135, 146424, 146425, 126586, 67838,133717} '::integer[ ]))
-> Bitmap Heap Scan on binarypackagere