We always join metabib.record_attr, and we always use an INNER join
to the core table, so keep that join first. Likewise with the join
to biblio.record_entry. Dynamic joins may be OUTER, though, and while
join reordering in Postgres is smart, let's not give it the chance to
fail.
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
$rank AS rank,
FIRST(mrd.attrs->'date1') AS tie_break
FROM metabib.metarecord_source_map m
- $$flat_plan{from}
$mra_join
$bre_join
+ $$flat_plan{from}
WHERE 1=1
$flat_where
GROUP BY 1