Difference Between Views and Tables in Performance

被刻印的时光 ゝ 提交于 2019-12-10 01:31:45

问题


What is best for tables with a lot of data?

I have a stored procedure that creates a report based on some filters. In my SP I read the table and put all the inner joins and formulas then in the where condition I put the filters.

Talking about performance what's better?

Create a view with all the joins OR read the table (as I'm doing)?


回答1:


Performance is a lot more dependent on having the appropriate indexes than if you are using a view or direct table access, which (except for materialized views) behave exactly the same way.




回答2:


It depends.

As long as the View does not contain aggregations (or constructs that require materialisation 'upfront'), it will be exactly the same performance (and in many cases can pass through where criteria with shortcircuiting by the optimiser)

Have you tried benchmarking in your specific cases?

@Otávio Décio beat me to it, by mentioning that having the 'correct' indexes will have a greater effect on performance.



来源:https://stackoverflow.com/questions/4576589/difference-between-views-and-tables-in-performance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!