"CN" <cnliou9@fastmail.fm> writes:
> The following view is, again, a simplified version. The real version,
> which takes 13 seconds, joins 2 more tables.
You're really doing your best to make sure we don't figure out what's
going on :-(
One thing I can see from your EXPLAIN ANALYZE results, though, is that
you've never VACUUMed or ANALYZEd these tables. If you had, there'd
be something other than the default 1000-row table size estimates:
> -> Index Scan using table1_pkey on table1
> (cost=0.00..52.00 rows=1000 width=100)
> (actual time=0.69..220.87 rows=9428 loops=1)
> -> Index Scan using table2_pkey on table2
> (cost=0.00..52.00 rows=1000 width=224)
> (actual time=0.63..959.95 rows=28482 loops=1)
and possibly the planner would have picked a more appropriate plan.
regards, tom lane