Performance of Tables vs. Views

后端 未结 3 1659
深忆病人
深忆病人 2021-02-19 19:35

Recently started working with a database in which the convention is to create a view for every table. If you assume that there is a one to one mapping between tables and views,

3条回答
  •  名媛妹妹
    2021-02-19 20:13

    Assuming the question is about non-materialized views -- Really depends on the query that the view is based on, and what is being done to it. Sometimes, the predicates can be pushed into the view query by the optimizer. If not, then it wouldn't be as good as against the table itself. Views are built on top of tables -- why would you expect that the performance would be better?

    Layering views, where you build one view on top of another, is a bad practice because you won't know about issues until run time. It's also less of a chance that predicate pushing will occur with layered views.

    Views can also be updateable -- they aren't a reliable means to restricting access to resources if someone has INSERT/UPDATE/DELETE privileges on the underlying tables.

    Materialized views are as good as tables, but are notoriously restrictive in what they support.

提交回复
热议问题