On Mon, Aug 4, 2014, at 06:40 PM, Jon Rosebaugh wrote: > On Tue, Jul 29, 2014, at 05:38 PM, David G Johnston wrote: > > You should at least provide some explain a/o explain analyse results. > > > > Not to sound pedantic here but you are not JOINing on the CTE, you are > > pushing it into WHERE clause via a pair of sub-selects. > > Fair criticisms. Okay, here we go. Table schemas at the end of the > email. My apologies for the length; I didn't want to try trimming out > "irrelevant" things that would end up causing actual changes to the > question I'm asking. I've run EXPLAIN ANALYZE for all the queries. Looks like line wrapping might have done a number on the explain output. I've put it all in the following pastebin just in case: https://gist.github.com/inklesspen/7e2577cf6fa9f73bc9c2