SQL Alias 与 dbo.prefix - 查询性能
假设您使用的是 MS SQL Server:
以下哪个查询执行速度最快,为什么?
我会猜测最后一个,因为我认为别名只解析到他们的表一次?
SELECT Account.AccountName,
AccountStatus.AccountState
FROM
dbo.Account
INNER JOIN dbo.AccountStatus ON Account.AccountStatusID = AccountStatus.AccountStatusID
GO
SELECT dbo.Account.AccountName,
dbo.AccountStatus.AccountState
FROM
dbo.Account
INNER JOIN dbo.AccountStatus ON dbo.Account.AccountStatusID = dbo.AccountStatus.AccountStatusID
GO
SELECT A.AccountName,
AST.AccountState
FROM
dbo.Account AS A
INNER JOIN dbo.AccountStatus AS AST ON A.AccountStatusID = AST.AccountStatusID
GO
Assuming you're using MS SQL Server:
Which of these queries will execute the fastest, and WHY?
I'm going to guess the last, as I'm thinking that Aliases are only resolved to their tables once?
SELECT Account.AccountName,
AccountStatus.AccountState
FROM
dbo.Account
INNER JOIN dbo.AccountStatus ON Account.AccountStatusID = AccountStatus.AccountStatusID
GO
SELECT dbo.Account.AccountName,
dbo.AccountStatus.AccountState
FROM
dbo.Account
INNER JOIN dbo.AccountStatus ON dbo.Account.AccountStatusID = dbo.AccountStatus.AccountStatusID
GO
SELECT A.AccountName,
AST.AccountState
FROM
dbo.Account AS A
INNER JOIN dbo.AccountStatus AS AST ON A.AccountStatusID = AST.AccountStatusID
GO
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)