SQL 选择性能前 1 VS 选择 1 [英] SQL select performance top 1 VS select 1

查看:41
本文介绍了SQL 选择性能前 1 VS 选择 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

select 1 from someTable where someColumn = #

select top 1 someColumn1 from someTable where someColumn2 = #

在大型桌子上哪个会更快...该表上根本没有索引,因此无法正常工作.

which one will be faster on a large scale table... got no indexes at all on that table so that wont work.

谢谢.

推荐答案

第一个选择一个值为 1(一个数字)和尽可能多的行的列,第二个返回所有列,但仅适用于第一行.

First one selects one column with value of literal 1 (a number) and as many rows as there are while second returns all the column but only for the first row.

由于他们做的事情不同,因此无法比较性能.

It is not possible to compare the performance since they are doing different things.

这篇关于SQL 选择性能前 1 VS 选择 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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