"Matt Klinker" <mklinker(at)gmail(dot)com> writes:
> Sorry for not including this extra bit originally. Below is the explain
> detail from both the query to the view that takes longer and then the query
> directly to the single table that performs quickly.
...
> -> Subquery Scan *SELECT* 1 (cost=0.00..1285922.80 rows=18384890
> width=251)
> -> Seq Scan on company (cost=0.00..1102073.90 rows=18384890
The presence of a Subquery Scan node tells me that either this is a much
older PG version than you stated, or there are some interesting details
to the query that you omitted. Please drop the fan-dance routine and
show us a complete reproducible test case.
regards, tom lane