EXPLAIN (ANALYZE TRUE, VERBOSE TRUE, COSTS TRUE, BUFFERS TRUE, TIMING TRUE) SELECT proposal.proposal.legacy_id AS "ProposalId" , note.entry_time as "EntryTime" , note.content as "Note" FROM proposal.note INNER JOIN proposal.proposal ON proposal.proposal.reference = note.proposal_reference WHERE legacy_read_by is null AND proposal.proposal.system_id = '11' AND proposal.proposal.legacy_organisation_id in ('2', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '42', '43', '44', '45', '46', '47', '48', '50', '52', '53', '54', '55', '181', '187', '188', '189', '190', '191', '192', '193', '194', '195', '196', '197', '199', '200', '202', '203', '204', '218', '221', '222', '223', '225', '226', '227', '228', '229', '230', '231', '232', '233', '235', '237', '239', '240', '241', '242', '243', '244', '245', '246', '247', '248', '249', '250', '251', '252', '253', '254', '255', '258', '259', '260', '261', '262', '263', '264', '265', '266', '267', '41') AND proposal.proposal.has_been_anonymised = false AND note.type_id = 3; 'Hash Join (cost=96937.18..210635.27 rows=1056 width=24) (actual time=1987.649..2086.253 rows=1065 loops=1)' ' Output: proposal.legacy_id, note.entry_time, note.content' ' Hash Cond: (note.proposal_reference = proposal.reference)' ' Buffers: shared hit=301 read=36610 written=2, temp read=3222 written=3096' ' I/O Timings: read=347.571 write=0.110' ' -> Bitmap Heap Scan on proposal.note (cost=4253.21..115399.45 rows=104875 width=36) (actual time=1.198..35.409 rows=2850 loops=1)' ' Output: note.entry_time, note.content, note.proposal_reference' ' Recheck Cond: ((note.type_id = 3) AND (note.legacy_read_by IS NULL))' ' Heap Blocks: exact=2383' ' Buffers: shared read=2413' ' I/O Timings: read=20.890' ' -> Bitmap Index Scan on note_type_id_entry_time_idx (cost=0.00..4226.99 rows=104875 width=0) (actual time=0.886..0.886 rows=2850 loops=1)' ' Index Cond: (note.type_id = 3)' ' Buffers: shared read=30' ' I/O Timings: read=0.407' ' -> Hash (cost=91092.63..91092.63 rows=86668 width=20) (actual time=1976.579..1976.579 rows=465120 loops=1)' ' Output: proposal.legacy_id, proposal.reference' ' Buckets: 8192 (originally 8192) Batches: 64 (originally 16) Memory Usage: 440kB' ' Buffers: shared hit=301 read=34197 written=2, temp written=2203' ' I/O Timings: read=326.681 write=0.110' ' -> Bitmap Heap Scan on proposal.proposal (cost=2871.35..91092.63 rows=86668 width=20) (actual time=77.416..1832.571 rows=465120 loops=1)' ' Output: proposal.legacy_id, proposal.reference' ' Recheck Cond: ((proposal.system_id = 11) AND (proposal.legacy_organisation_id = ANY ('{2,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,50,52,53,54,55,181,187,188,189,190,191,192,193,194,195,196,197,199,200,202,203,204,218,221,222,223,225,226,227,228,229,230,231,232,233,235,237,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,258,259,260,261,262,263,264,265,266,267,41}'::integer[])))' ' Rows Removed by Index Recheck: 1944770' ' Filter: (NOT proposal.has_been_anonymised)' ' Rows Removed by Filter: 993208' ' Heap Blocks: exact=3983 lossy=27989' ' Buffers: shared hit=301 read=34197 written=2' ' I/O Timings: read=326.681 write=0.110' ' -> Bitmap Index Scan on proposal_has_been_anonymised_system_id_legacy_organisation__idx (cost=0.00..2849.68 rows=86668 width=0) (actual time=76.850..76.850 rows=465120 loops=1)' ' Index Cond: ((proposal.has_been_anonymised = false) AND (proposal.system_id = 11) AND (proposal.legacy_organisation_id = ANY ('{2,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,50,52,53,54,55,181,187,188,189,190,191,192,193,194,195,196,197,199,200,202,203,204,218,221,222,223,225,226,227,228,229,230,231,232,233,235,237,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,258,259,260,261,262,263,264,265,266,267,41}'::integer[])))' ' Buffers: shared hit=301 read=2225' ' I/O Timings: read=28.659' 'Planning time: 1.001 ms' 'Execution time: 2086.603 ms'