Merge Join (cost=1601307324.02..1609737599.30 rows=146429 width=182) Merge Cond: (("outer"."?column16?" = "inner"."?column8?") AND ("outer"."?column17?" = "inner"."?column9?")) Join Filter: ((("inner"."startDate")::date < ("outer"."startDate")::date) AND (NOT (subplan))) -> Sort (cost=1601007252.32..1601008119.73 rows=346963 width=154) Sort Key: ("Action"."jurorId")::integer, ("Action"."juryYear")::bpchar -> Index Scan using "Action_pkey" on "Action" (cost=0.00..1600959059.08 rows=346963 width=154) Index Cond: (("countyNo")::smallint = 40) Filter: ((("actionCode")::bpchar <> 'APOOL'::bpchar) AND (("actionCode")::bpchar <> 'RPOOL'::bpchar) AND (("actionCode")::bpchar <> 'APAN'::bpchar) AND (("actionCode")::bpchar <> 'RPAN'::bpchar) AND (("actionCode")::bpchar <> 'MPOOL'::bpchar) AND (("actionCode")::bpchar <> 'MPAN'::bpchar) AND (("actionCode")::bpchar <> 'PR'::bpchar) AND (("actionCode")::bpchar <> 'JPP'::bpchar) AND (("actionCode")::bpchar <> 'MFROM'::bpchar) AND (("actionCode")::bpchar <> 'MNEXT'::bpchar) AND (subplan) AND ((("poolId" IS NULL) AND (subplan)) OR (("panelId" IS NULL) AND (subplan)))) SubPlan -> Index Scan using "Action_pkey" on "Action" a1 (cost=0.00..436.81 rows=1 width=0) Index Cond: ((("countyNo")::smallint = 40) AND (("countyNo")::smallint = ($0)::smallint) AND (("actionSeqNo")::integer < ($3)::integer) AND (("juryYear")::bpchar = ($1)::bpchar)) Filter: ((("jurorId")::integer = ($2)::integer) AND ((("actionCode")::bpchar = 'APAN'::bpchar) OR (("actionCode")::bpchar = 'MPAN'::bpchar))) -> Index Scan using "Action_pkey" on "Action" a1 (cost=0.00..436.81 rows=1 width=0) Index Cond: ((("countyNo")::smallint = 40) AND (("countyNo")::smallint = ($0)::smallint) AND (("actionSeqNo")::integer < ($3)::integer) AND (("juryYear")::bpchar = ($1)::bpchar)) Filter: ((("jurorId")::integer = ($2)::integer) AND ((("actionCode")::bpchar = 'APOOL'::bpchar) OR (("actionCode")::bpchar = 'MPOOL'::bpchar))) -> Index Scan using "JuryControl_pkey" on "JuryControl" jc (cost=0.00..3.73 rows=1 width=0) Index Cond: ((("countyNo")::smallint = 40) AND (("countyNo")::smallint = ($0)::smallint)) Filter: (("juryYear")::bpchar = ($1)::bpchar) -> Sort (cost=300071.69..300994.54 rows=369137 width=50) Sort Key: (a2."jurorId")::integer, (a2."juryYear")::bpchar -> Bitmap Heap Scan on "Action" a2 (cost=14613.56..258005.86 rows=369137 width=50) Recheck Cond: (("countyNo")::smallint = 40) Filter: ((("actionCode")::bpchar = 'APOOL'::bpchar) OR (("actionCode")::bpchar = 'RPOOL'::bpchar) OR (("actionCode")::bpchar = 'APAN'::bpchar) OR (("actionCode")::bpchar = 'RPAN'::bpchar) OR (("actionCode")::bpchar = 'MPOOL'::bpchar) OR (("actionCode")::bpchar = 'MPAN'::bpchar)) -> Bitmap Index Scan on "Action_pkey" (cost=0.00..14613.56 rows=1824447 width=0) Index Cond: (("countyNo")::smallint = 40) SubPlan -> Index Scan using "Action_pkey" on "Action" a3 (cost=0.00..9.57 rows=1 width=176) Index Cond: ((("countyNo")::smallint = 40) AND (("countyNo")::smallint = ($0)::smallint) AND (("countyNo")::smallint = ($5)::smallint) AND (("juryYear")::bpchar = ($1)::bpchar) AND (("juryYear")::bpchar = ($6)::bpchar)) Filter: ((("jurorId")::integer = ($2)::integer) AND ((("actionCode")::bpchar = 'APOOL'::bpchar) OR (("actionCode")::bpchar = 'RPOOL'::bpchar) OR (("actionCode")::bpchar = 'APAN'::bpchar) OR (("actionCode")::bpchar = 'RPAN'::bpchar) OR (("actionCode")::bpchar = 'MPOOL'::bpchar) OR (("actionCode")::bpchar = 'MPAN'::bpchar)) AND (("startDate")::date < ($4)::date) AND (("jurorId")::integer = ($7)::integer) AND (("startDate")::date >= ($8)::date) AND ((("startDate")::date > ($8)::date) OR (("actionSeqNo")::integer > ($9)::integer))) (29 rows)