简体   繁体   English

SQL:在视图上查询-执行缓慢

[英]SQL: Query on View - slow execution

Sql newbie here. SQL新手在这里。 If you run a query that join two tables and one view. 如果运行的查询将两个表和一个视图连接在一起。 If the view is composed of three tables. 如果视图由三个表组成。 Does it slow down the query? 它会减慢查询速度吗? Is there anyway to speed it up? 反正有加快它的速度吗?

A view is not more expensive than writing out the SQL, and sometimes even faster. 视图并没有写出SQL昂贵,有时甚至更快。 The database knows about the view, and can cache its execution plan. 数据库知道该视图,并且可以缓存其执行计划。

But querying on two tables is slower than querying on five tables, whether the three additional tables are in a view or not. 但是,无论是否在视图中,另外三个表的查询都比五个表的查询慢。

根据您的有限输入,唯一的答案是:确保正在使用索引

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM