gpt4 book ai didi

sql - TeraData SQL中 "TOP"和 "SAMPLE"之间的区别

转载 作者:行者123 更新时间:2023-12-04 10:21:08 25 4
gpt4 key购买 nike

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.

关于sql - TeraData SQL中 "TOP"和 "SAMPLE"之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6374576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com