On 5/9/07, Ashish Karalkar <ashish.karalkar@xxxxxxxxxxxxxxxxx> wrote:
Thanks Brent for your replay, What about the Disadvantages, Performance issues [of views]
Views are pretty much neutral from a performance perspective. There are certain small considerations here and there to think about but you should really be focusing on how they impact your development and design strategies. Probably there are two disadvantages of using views. The first is that the introduce dependencies on your tables so that whenever you need to certain things to your table you have to drop the view, do the thing (like drop a column) and re-create the view. Second issue is that views are not updatable without the introduction of rules which are extra dependencies and can be tricky to write. Now the first problem is not really a problem...in fact, views are a great way to tell the dba what applications are doing and gives him a chance to introduce application compatibility if the table structures change. So I count this as a feature of using views although it will feel like extra work to do, especially in the beginning. At some point, views (especially trivial ones) in PostgreSQL will become automatically updatable which will mitigate the impact of the second disadvantage. If and when that happens, IMNSHO, Views are a critical foundation to good development. Complex queries drifting around in various applications is A Bad Thing, and views allow you to control this and provide much better encapsulation of the database and exercise control over what's going on. Many application developers are uncomfortable with the idea of views (and other high level database features like functions) but when used properly, the benefits they can bring to your development and maintenance can be really dramatic. Use them. merlin