是一个

select *  from myView

比查询本身更快地创建视图(为了拥有相同的resultSet):

select * from ([query to create same resultSet as myView])

?

我不完全清楚视图是否使用了某种缓存,使其比简单查询更快。


当前回答

不。View只是实际的长SQL查询的一种简短形式。但是,你可以说实际查询比视图命令/查询更快。

首先视图查询将转换为简单查询,然后执行,因此视图查询将比简单查询执行更多的时间。

当您使用连接b/w多个表时,可以使用sql视图,以简单的方式一次又一次地重用复杂的查询。

其他回答

从视图或表中选择没有太大意义。

当然,如果视图没有不必要的连接、字段等。您可以检查用于提高View性能的查询、连接和索引的执行计划。

您甚至可以为更快的搜索需求在视图上创建索引。http://technet.microsoft.com/en-us/library/cc917715.aspx

但是如果你搜索'%…SQL引擎将不能从文本列上的索引中获益。如果你能强迫你的用户进行类似“……比那快多了

参考asp论坛上的回答: https://forums.asp.net/t/1697933.aspx?Which+is+faster+when+using+SELECT+query+VIEW+or+Table+

In SQL Server at least, Query plans are stored in the plan cache for both views and ordinary SQL queries, based on query/view parameters. For both, they are dropped from the cache when they have been unused for a long enough period and the space is needed for some other newly submitted query. After which, if the same query is issued, it is recompiled and the plan is put back into the cache. So no, there is no difference, given that you are reusing the same SQL query and the same view with the same frequency.

显然,在一般情况下,一个视图,根据它的本质(有人认为它被经常使用,使它成为一个视图)通常比任何任意的SQL语句更有可能被“重用”。

存储执行计划应该会有一些微不足道的好处,但可以忽略不计。

没有实际的区别,如果你读BOL,你会发现你的普通旧SQL SELECT * FROM X确实利用了计划缓存等。

我希望这两个查询的执行是相同的。视图只不过是一个存储的查询定义,视图没有缓存或存储数据。当您运行第一个查询时,优化器将有效地将其转换为第二个查询。