Re:Following a Select Statement Through Postgres Internals
by Animats on Monday October 13, 2014 @03:18PM
(#8450093)
Depends on the contents of the database. The query optimizer doesn't know, at optimization time, how many hits such a statement will produce. Given a database with only a few entries with the same name, the sort cost is tiny. If there are a lot of hits, it's expensive.
[ Parent
| on HN ]
Re:Following a Select Statement Through Postgres Internals
by yangyang on Monday October 13, 2014 @04:34PM
(#8450498)
It can estimate though, using per-column statistics. ANALYZE (and the autoanalyze background process) update these in PostgreSQL.
These stats are a huge part of cost-based query optimisation, which all major DBMSs do these days.
Details here: http://www.postgresql.org/docs/9.3/static/planner-stats.html