Posts

Showing posts from March, 2018

The Use of Views Has No Impact on Query Performance in PostgreSQL

More evidence that PostgreSQL is the best database. The documentation supports one of my strongest beliefs about database design: Making liberal use of views is a key aspect of good SQL database design. Views allow you to encapsulate the details of the structure of your tables, which might change as your application evolves, behind consistent interfaces. Views can be used in almost any place a real table can be used. Building views upon other views is not uncommon. Source: https://www.postgresql.org/docs/10/static/tutorial-views.html In answer to a question about the impact of views on query performance, veteran PostgreSQL core developer Bruce Momjian gave the following answer: They have no impact whatsoever. The parser thinks the view is a real table. The query structure gets passed to the re-writer and the re-writer wipes out the view and substitutes the underlying tables. And that re-write is what gets passed to the query optimizer. The optimizer doesn't see the v