Kim Bisgaard <kib+pg@dmi.dk> writes:
> W.r.t. your rewrite of the query, I get this "ERROR: could not devise a
> query plan for the given query" but no further details - I will try google
Which PG version are you using again? That should be fixed in 7.4.3
and later.
regards, tom lane