Antonio Batovanja wrote:
Laurenz Albe wrote:
Antonio Batovanja wrote:
I'm having trouble understanding, why a specific query on a small
database is taking so long...
Before I try to understand the execution plans:
Have you run ANALYZE on the tables involved before you ran the query?
Hi,
Just to be on the safe side, I've run ANALYZE now.
Here are the query plans for the two queries:
I suspect a misunderstanding here. What Laurenz probably meant is to run
analyze on the involved _tables_ so the statistics data is refreshed.
If the query planner runs with outdated statistics, queries may perform
very poorly. Try
vacuum full analyze yourdatabase
To fully vacuum your database and analyze all tables.
(vacuum full is extra, but can't hurt.)
http://www.postgresql.org/docs/8.1/static/sql-vacuum.html
http://www.postgresql.org/docs/8.1/static/sql-analyze.html
Regards, Erwin