【发布时间】:2012-04-12 13:26:48
【问题描述】:
我们有一个在 MSAccess 中运行但使用 SQL Server 作为后端数据库的应用程序。这会生成一个查询来检查它可以访问哪些视图,对于普通用户来说,这最多需要 18 秒。对于属于 db_owner 角色的所有用户,需要 0.2 秒。有什么办法可以为普通用户调整这个吗?也许我可以在 Access 中做些什么?我不想给他们db_owner,重写应用程序不使用Access是不可能的。
这是查询:
select
object_name(id),
user_name(uid), type,
ObjectProperty(id, N'IsMSShipped'),
ObjectProperty(id, N'IsSchemaBound')
from sysobjects
where type = N'V'
and permissions(id) & 4096 <> 0
使用 MS Access 2003、SQL Server 2008 R2
【问题讨论】:
-
当您在其中一个用户名下运行查询时返回了多少视图?
-
它为 db_owners 返回 1351 行,为普通用户返回 1344 行
-
执行计划相同。在 winmerge 中比较它们,唯一的区别是 QueryPlan 元素,其中 CompileTime 和 CompileCPU 略有不同(两者都为 6,两者都为 7),以及 RunTimeCountersPerThread 元素,其中 ActualRows 对于普通用户为 1344,对于 db_owners 为 1351
标签: sql-server performance ms-access database-performance sqlperformance