查询在本地SSMS上花费的时间比在远程SSMS上花费的时间更多 [英] Query taking more time on local SSMS than remote

查看:85
本文介绍了查询在本地SSMS上花费的时间比在远程SSMS上花费的时间更多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行带有4个内部联接和两个 WHERE条件的select语句时,在本地SSMS中花了13-15 s(我执行了5次)。但是,当我从另一台服务器的SSMS连接同一实例并执行相同的查询时,第一次执行需要5秒,然后花费了0秒!我正在使用相同的用户SA。

When I am executing a select statement with 4 'inner' joins and two 'WHERE' conditions it took 13-15 s in local SSMS (I have executed 5 times). But when I connect the same instance from another server's SSMS and execute the same query it took 5 s to execute first time and then it took 0 s! I am using the same user SA.

有没有可能的解释?

主机实例是SQL 2008,远程实例具有SQL 2008 R2。

Host instance is SQL 2008 and Remote instance has SQL 2008 R2.

推荐答案

如果您的查询返回的数据要显示在本地SSMS中,则该数据需要从服务器传输到本地SSMS。执行时间包括将数据从服务器传输到本地SSMS的时间。因此,执行时间是执行脚本和获取数据以显示它的组合。

If your query is returning data to display in your local SSMS then this data needs to be transferred from the server to your local SSMS. The time to transfer the data from the server to your local SSMS is included in the execution time. So, the execution time is a combination of executing the script and fetching the data in order to display it.

您可能希望包括客户统计信息,然后查看

You might want to "Include Client Statistics" and then review the row "Bytes received from server" in the "Client Statistic" tab of the result window.

为了验证我的假设,您可以更改选择,使其仅执行而无需获取数据。

In order to verify my assumption you can alter your select only to execute without fetching the data.

这篇关于查询在本地SSMS上花费的时间比在远程SSMS上花费的时间更多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆