如何比较两个查询? [英] How to compare two queries?

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

问题描述

我如何比较两个查询 X 和 Y 并说 X 比 Y 更好,因为它们在小案例场景中花费的时间几乎相同?

How can I compare two queries X and Y and say that X is better than Y, when they both take almost the same time in small cases scenarios?

问题是我有两个查询应该在一个非常大的数据库上运行,所以运行和评估不是一个很好的选择.因此,我们创建了一个小型数据库来执行一些测试.评估哪个查询更好是一个问题,因为在我们的测试基础上,它们几乎同时运行(大约 5 分钟).除了返回所需的时间,还有什么方法可以衡量查询的好坏?

The problem is that I have two queries that are supposed to run on a very big database, so run and evaluate is not quite an option. Therefore, we created a small database to perform some tests. Evaluating which query is better is a problem, since on our test base, they run in almost the same time (about 5 minutes). Besides the time taken to return, what is another way to measure how good a query is?

推荐答案

SET STATISTICS IO ON
SET STATISTICS TIME ON

运行查询并比较各种表的逻辑读取和执行时间.

Run the queries and compare logical reads for the various tables and execution times.

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

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