加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

TeraData SQL中“TOP”和“SAMPLE”的区别

发布时间:2020-12-12 06:53:08 所属栏目:MsSql教程 来源:网络整理
导读:TeraData SQL中“TOP”和“SAMPLE”有什么区别?它们是一样的吗? 解决方法 从 TOP vs SAMPLE开始: TOP 10 means “first 10 rows in sorted order”. If you don’t have an ORDER BY, then by extension it will be interpreted as asking for “ANY 10 ro
TeraData SQL中“TOP”和“SAMPLE”有什么区别?它们是一样的吗?

解决方法

从 TOP vs SAMPLE开始:

TOP 10 means “first 10 rows in sorted
order”. If you don’t have an ORDER BY,
then by extension it will be
interpreted as asking for “ANY 10
rows” in any order. The optimizer is
free to select the cheapest plan it
can find and stop processing as soon
as it has found enough rows to return.

If this query is the only thing
running on your system,TOP may appear
to always give you exactly the same
answer,but that behavior is NOT
guaranteed.

SAMPLE,as you have observed,does extra processing to try to randomize the result set yet maintain the same approximate distribution. At a very simple level,for example,it could pick a random point at which to start scanning the table and a number of rows to skip between rows that are returned.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读