Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net> writes:
> the explain analyze of which is (I've actually gotten it to
> work better in the meantime as you can see):
Looks like most of the problem is in the subquery scans on v_staff,
which seems to be a rather expensive view :-(. Maybe you can
simplify that a bit.
regards, tom lane