Original query:

Unique  (cost=73.87..73.89 rows=1 width=60)
  Output: p."caseNo", c."caseType", p."countyNo", p."partyNo", ch."eventType", ch."eventDate", (CASE WHEN ((ch."userId")::text = 'CANALYS'::text) THEN 'CCAP Conversion'::character varying ELSE (ch."userId")::character varying END)
  ->  Sort  (cost=73.87..73.88 rows=1 width=60)
        Output: p."caseNo", c."caseType", p."countyNo", p."partyNo", ch."eventType", ch."eventDate", (CASE WHEN ((ch."userId")::text = 'CANALYS'::text) THEN 'CCAP Conversion'::character varying ELSE (ch."userId")::character varying END)
        Sort Key: p."caseNo", c."caseType", p."countyNo", p."partyNo", ch."eventDate", (CASE WHEN ((ch."userId")::text = 'CANALYS'::text) THEN 'CCAP Conversion'::character varying ELSE (ch."userId")::character varying END)
        ->  Nested Loop Anti Join  (cost=3.80..73.86 rows=1 width=60)
              Output: p."caseNo", c."caseType", p."countyNo", p."partyNo", ch."eventType", ch."eventDate", CASE WHEN ((ch."userId")::text = 'CANALYS'::text) THEN 'CCAP Conversion'::character varying ELSE (ch."userId")::character varying END
              Join Filter: ((c."countyNo")::smallint = (c."countyNo")::smallint)
              ->  Nested Loop Anti Join  (cost=3.38..73.38 rows=1 width=50)
                    Output: p."caseNo", p."countyNo", p."partyNo", c."caseType", c."caseNo", c."countyNo", ch."eventType", ch."eventDate", ch."userId"
                    ->  Nested Loop Anti Join  (cost=3.09..73.04 rows=1 width=50)
                          Output: p."caseNo", p."countyNo", p."partyNo", c."caseType", c."caseNo", c."countyNo", ch."eventType", ch."eventDate", ch."userId"
                          ->  Nested Loop  (cost=2.53..72.45 rows=1 width=50)
                                Output: p."caseNo", p."countyNo", p."partyNo", c."caseType", c."caseNo", c."countyNo", ch."eventType", ch."eventDate", ch."userId"
                                Inner Unique: true
                                ->  Nested Loop  (cost=2.25..72.15 rows=1 width=53)
                                      Output: p."caseNo", p."countyNo", p."partyNo", p."partyType", c."caseType", c."caseNo", c."countyNo", ch."eventType", ch."eventDate", ch."userId"
                                      Inner Unique: true
                                      ->  Nested Loop Anti Join  (cost=2.11..71.99 rows=1 width=55)
                                            Output: p."caseNo", p."countyNo", p."partyNo", p."partyType", c."caseType", c."caseNo", c."countyNo", ch."eventType", ch."eventDate", ch."userId", ch."countyNo"
                                            ->  Nested Loop  (cost=1.55..57.21 rows=1 width=70)
                                                  Output: p."caseNo", p."countyNo", p."partyNo", p."partyType", c."caseType", c."caseNo", c."countyNo", ch."eventType", ch."eventDate", ch."userId", ch."caseNo", ch."countyNo", ch."histSeqNo"
                                                  ->  Nested Loop  (cost=0.99..56.16 rows=1 width=50)
                                                        Output: c."caseType", c."caseNo", c."countyNo", ch."eventType", ch."eventDate", ch."userId", ch."caseNo", ch."countyNo", ch."histSeqNo"
                                                        Inner Unique: true
                                                        Join Filter: ((ec."caseType")::text = (c."caseType")::text)
                                                        ->  Nested Loop  (cost=0.56..27.14 rows=44 width=35)
                                                              Output: ec."caseType", ch."eventType", ch."eventDate", ch."userId", ch."caseNo", ch."countyNo", ch."histSeqNo"
                                                              ->  Seq Scan on public."EFilingCaseType" ec  (cost=0.00..0.40 rows=30 width=7)
                                                                    Output: ec."caseType", ec."dateMandatory"
                                                                    Filter: (ec."dateMandatory" IS NOT NULL)
                                                              ->  Index Scan using "CaseHist_EventDate" on public."CaseHist" ch  (cost=0.56..0.88 rows=1 width=32)
                                                                    Output: ch."caseNo", ch."histSeqNo", ch."countyNo", ch."caseType", ch."eventAmt", ch."eventDate", ch."eventType", ch."userId", ch."courtRptrCode", ch."ctofcNo", ch."prevRespCtofc", ch.tag, ch."tapeCounterNo", ch."tapeLoc", ch."wcisReported", ch."weightPd", ch."weightTime", ch."dktTxt", ch."sealCtofcNo", ch."sccaCaseNo", ch."isCourtType", ch."insertedDate"
                                                                    Index Cond: (((ch."eventDate")::date = (ec."dateMandatory")::date) AND ((ch."eventType")::text = 'MECC'::text))
                                                                    Filter: ((ch."userId")::text = 'CANALYS'::text)
                                                        ->  Index Scan using "Case_isEFiling" on public."Case" c  (cost=0.42..0.65 rows=1 width=18)
                                                              Output: c."caseType", c."caseNo", c."countyNo"
                                                              Index Cond: (((c."caseNo")::text = (ch."caseNo")::text) AND ((c."countyNo")::smallint = (ch."countyNo")::smallint))
                                                              Filter: ((c."caseType")::text = ANY ('{PA,FA,SC,CV,CF,CM,CT,PR,IN,GN,ME}'::text[]))
                                                  ->  Index Scan using "Party_pkey" on public."Party" p  (cost=0.56..0.95 rows=10 width=20)
                                                        Output: p."caseNo", p."countyNo", p."partyNo", p."partyType"
                                                        Index Cond: (((p."caseNo")::text = (c."caseNo")::text) AND ((p."countyNo")::smallint = (c."countyNo")::smallint))
                                                        Filter: ((NOT p."isENotice") AND ((p."statusCode")::text = 'AC'::text))
                                            ->  Index Scan using "CaseHist_pkey" on public."CaseHist" ch1  (cost=0.56..7.84 rows=1 width=17)
                                                  Output: ch1."caseNo", ch1."histSeqNo", ch1."countyNo", ch1."caseType", ch1."eventAmt", ch1."eventDate", ch1."eventType", ch1."userId", ch1."courtRptrCode", ch1."ctofcNo", ch1."prevRespCtofc", ch1.tag, ch1."tapeCounterNo", ch1."tapeLoc", ch1."wcisReported", ch1."weightPd", ch1."weightTime", ch1."dktTxt", ch1."sealCtofcNo", ch1."sccaCaseNo", ch1."isCourtType", ch1."insertedDate"
                                                  Index Cond: (((ch1."caseNo")::text = (ch."caseNo")::text) AND ((ch1."histSeqNo")::smallint > (ch."histSeqNo")::smallint) AND ((ch1."countyNo")::smallint = (ch."countyNo")::smallint))
                                                  Filter: ((ch1."eventType")::text = 'CREF'::text)
                                      ->  Index Only Scan using "County_pkey" on public."County" co  (cost=0.14..0.16 rows=1 width=2)
                                            Output: co."countyNo"
                                            Index Cond: (co."countyNo" = (c."countyNo")::smallint)
                                ->  Index Scan using "CaseTypePrtyType_pkey" on public."CaseTypePrtyType" "CTPT"  (cost=0.28..0.30 rows=1 width=6)
                                      Output: "CTPT"."caseType", "CTPT"."partyType", "CTPT".descr, "CTPT"."isActive", "CTPT"."isSide1FirstParty", "CTPT"."isSide1", "CTPT"."isSide2", "CTPT"."isSide2FirstParty", "CTPT"."printNotice"
                                      Index Cond: ((("CTPT"."caseType")::text = "substring"((p."caseNo")::text, 5, 2)) AND (("CTPT"."partyType")::text = (p."partyType")::text))
                                      Filter: "CTPT"."printNotice"
                          ->  Index Scan using "AttyParty_pkey" on public."AttyParty" ap  (cost=0.56..0.58 rows=1 width=17)
                                Output: ap."partyNo", ap."caseNo", ap."countyNo"
                                Index Cond: (((ap."caseNo")::text = (p."caseNo")::text) AND ((p."partyNo")::smallint = (ap."partyNo")::smallint) AND ((p."countyNo")::smallint = (ap."countyNo")::smallint))
                                Filter: ((ap."withdrewDate" IS NULL) OR ((ap."withdrewDate")::date > CURRENT_DATE))
                    ->  Index Only Scan using "PartyEFileNotice_pkey" on public."PartyEFileNotice" en  (cost=0.29..0.31 rows=1 width=17)
                          Output: en."countyNo", en."caseNo", en."partyNo"
                          Index Cond: ((en."countyNo" = (p."countyNo")::smallint) AND (en."caseNo" = (p."caseNo")::text) AND (en."partyNo" = (p."partyNo")::smallint))
              ->  Index Scan using "CaseMaint_pkey" on public."CaseMaint" m  (cost=0.42..0.47 rows=1 width=13)
                    Output: m."caseNo", m."histSeqNo", m."countyNo", m."newMaint", m."partyNo"
                    Index Cond: ((c."caseNo")::text = (m."caseNo")::text)
                    Filter: ((m."newMaint")::text = 'WA'::text)