Hash Join (cost=27010.45..254388.49 rows=253820 width=24) Hash Cond: ("outer".template_id = "inner".id) -> Merge Join (cost=27008.52..250579.25 rows=253820 width=24) Merge Cond: ("outer".data_id = "inner".id) -> Index Scan using idx_dv_data_id on data_values (cost=0.00..197001.44 rows=9127404 width=16) -> Sort (cost=27008.52..27218.04 rows=83806 width=16) Sort Key: data.id -> Index Scan using idx_d_entered on data (cost=0.00..19266.46 rows=83806 width=16) Index Cond: (((('now'::text)::timestamp(6) with time zone)::timestamp without time zone - '00:01:00'::interval) < entered) Filter: ((machine_id = 2) OR (machine_id = 3)) -> Hash (cost=1.74..1.74 rows=74 width=8) -> Seq Scan on datatemplate_intervals (cost=0.00..1.74 rows=74 width=8) (12 rows)