2个查询的时间比较 [英] Time Comparison of 2 Queries

查看:68
本文介绍了2个查询的时间比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1.选择*来自员工



2.选择EmployeeCode,EmployeeName,Address1,Address2,Address3,来自员工的图片





从以上2个查询中经过的时间越少。请详细说明。





表格结构:员工





列名-----数据类型

EmployeeCode ----- varchar(15)

员工姓名----- varchar(40)

地址1 --------- varchar(30)

地址2 --------- varchar (30)

地址3 --------- varchar(30)

图片------------图片

1.Select * From Employee

2.Select EmployeeCode,EmployeeName,Address1,Address2,Address3,Image From Employee


From the above 2 queries Which Elapsed time is less. please explain with details.


Table Structure: Employee


Column Name-----Data Type
EmployeeCode-----varchar(15)
EmployeeName-----varchar(40)
Address1---------varchar(30)
Address2---------varchar(30)
Address3---------varchar(30)
Image------------Image

推荐答案

嗨Pravin,



你应该问google这个。

否问题我搜索过你你可以找到原因这里 [ ^ ]。



顺便说一句感谢您提出这个问题。



希望这对您有所帮助。



问候,

RK
Hi Pravin,

You should have asked google for this.
No problem I did search for you you can find reason here[^] .

By the way Thanks for asking this question.

Hope this helps you a bit.

Regards,
RK


In除了RK的解决方案1之外,我想提供另一个有用的链接:

SQL SERVER - 运行T-SQL查询时的时间延迟 - WAITFOR简介 [ ^ ]

获取IO和SQL Server查询的时间统计信息 [ ^ ]



有几项方法可以提高查询性能(执行时间)。

7 performan更快速SQL查询的技巧 [ ^ ]

查询效果 [ ^ ]



Finall结论:包含必要列列表的查询总是快于 SELECT *
In addition to solution 1 by RK, i would like to provide another useful links:
SQL SERVER – Time Delay While Running T-SQL Query – WAITFOR Introduction[^]
Getting IO and time statistics for SQL Server queries[^]

There are several things to do to increase query performance (time of execution).
7 performance tips for faster SQL queries[^]
Query Performance[^]

Finall conclusion: a query with list of necessary columns is always faster than SELECT *!


一般的答案是不可能的,因为如果一个记录的包大小适合意外 - 那么就没有区别了查询性能。



无论如何我建议:

a。)只查询你需要的字段。意味着没有SELECT *

b。)Image降低性能的几率是高

c。)总是使用where。想象一下,你有一张包含数百万条记录的桌子....



请注意♥...ЯҠ...♥在他的回答中的链接
A general answer is not possible, because in case packages size for one record fits -by "accident"- then there will be no difference in query performance.

Anyway I suggest:
a.) Query only the fields you need. Means no SELECT *
b.) The chance that Image decrease the perfromance is "high"
c.) Always use a where. Imagine you have a table with millions of records....

Please note the link by ♥…ЯҠ…♥ in his answer


这篇关于2个查询的时间比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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