This is the core work: select BinaryPackageRelease.binarypackagename from BinaryPackagePublishingHistory, BinaryPackageRelease, DistroArchSeries WHERE BinaryPackagePublishingHistory.binarypackagerelease = BinaryPackageRelease.id AND BinaryPackagePublishingHistory.distroarchseries = DistroArchSeries.id AND DistroArchSeries.distroseries = 103 AND BinaryPackagePublishingHistory.status IN (2, 1) AND BinaryPackagePublishingHistory.archive IN (1, 534) AND BinaryPackageRelease.binarypackagename IN (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);
Hash Join (cost=179847.88..408910.32 rows=4516 width=4) (actual time=1006.846..2036.877 rows=720 loops=1) Hash Cond: (binarypackagepublishinghistory.binarypackagerelease = binarypackagerelease.id) -> Hash Join (cost=24542.79..252348.43 rows=96931 width=4) (actual time=502.347..1714.819 rows=215414 loops=1) Hash Cond: (binarypackagepublishinghistory.distroarchseries = distroarchseries.id) -> Bitmap Heap Scan on binarypackagepublishinghistory (cost=24540.67..246288.13 rows=1357031 width=8) (actual time=502.045..1173.741 rows=1752450 loops=1) Recheck Cond: ((archive = ANY ('{1,534}'::integer[])) AND (status = ANY ('{2,1}'::integer[]))) -> Bitmap Index Scan on securebinarypackagepublishinghistory__archive__status__idx (cost=0.00..24201.41 rows=1357031 width=0) (actual time=443.611..443.611 rows=1752450 loops=1) Index Cond: ((archive = ANY ('{1,534}'::integer[])) AND (status = ANY ('{2,1}'::integer[]))) -> Hash (cost=2.05..2.05 rows=6 width=4) (actual time=0.063..0.063 rows=6 loops=1) -> Seq Scan on distroarchseries (cost=0.00..2.05 rows=6 width=4) (actual time=0.035..0.057 rows=6 loops=1) Filter: (distroseries = 103) -> Hash (cost=154514.79..154514.79 rows=63224 width=8) (actual time=115.750..115.750 rows=67260 loops=1) -> Bitmap Heap Scan on binarypackagerelease (cost=1770.43..154514.79 rows=63224 width=8) (actual time=24.762..88.315 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=17.567..17.567 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[])) Total runtime: 2037.123 ms
This is the core work: lease.binarypac kagename from agePublishingHi story, ageRelease, Series blishingHistory .binarypackager elease = BinaryPackageRe lease.id blishingHistory .distroarchseri es = DistroArchSeries.id s.distroseries = 103 blishingHistory .status IN (2, 1) blishingHistory .archive IN (1, 534) lease.binarypac kagename IN (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);
select BinaryPackageRe
BinaryPack
BinaryPack
DistroArch
WHERE BinaryPackagePu
AND BinaryPackagePu
AND DistroArchSerie
AND BinaryPackagePu
AND BinaryPackagePu
AND BinaryPackageRe
Hash Join (cost=179847. 88..408910. 32 rows=4516 width=4) (actual time=1006. 846..2036. 877 rows=720 loops=1) ublishinghistor y.binarypackage release = binarypackagere lease.id) 79..252348. 43 rows=96931 width=4) (actual time=502. 347..1714. 819 rows=215414 loops=1) ublishinghistor y.distroarchser ies = distroarchserie s.id) blishinghistory (cost=24540. 67..246288. 13 rows=1357031 width=8) (actual time=502. 045..1173. 741 rows=1752450 loops=1)
Recheck Cond: ((archive = ANY ('{1,534} '::integer[ ])) AND (status = ANY ('{2,1} '::integer[ ]))) kagepublishingh istory_ _archive_ _status_ _idx (cost=0. 00..24201. 41 rows=1357031 width=0) (actual time=443. 611..443. 611 rows=1752450 loops=1)
Index Cond: ((archive = ANY ('{1,534} '::integer[ ])) AND (status = ANY ('{2,1} '::integer[ ])))
Filter: (distroseries = 103) 79..154514. 79 rows=63224 width=8) (actual time=115. 750..115. 750 rows=67260 loops=1) lease (cost=1770. 43..154514. 79 rows=63224 width=8) (actual time=24.762..88.315 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[ ])) lease_binarypac kagename_ key (cost=0.00..1754.62 rows=63224 width=0) (actual time=17.567..17.567 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[ ]))
Hash Cond: (binarypackagep
-> Hash Join (cost=24542.
Hash Cond: (binarypackagep
-> Bitmap Heap Scan on binarypackagepu
-> Bitmap Index Scan on securebinarypac
-> Hash (cost=2.05..2.05 rows=6 width=4) (actual time=0.063..0.063 rows=6 loops=1)
-> Seq Scan on distroarchseries (cost=0.00..2.05 rows=6 width=4) (actual time=0.035..0.057 rows=6 loops=1)
-> Hash (cost=154514.
-> Bitmap Heap Scan on binarypackagere
-> Bitmap Index Scan on binarypackagere
Total runtime: 2037.123 ms