|
Archives of the TeradataForumMessage Posted: Wed, 10 Jan 2001 @ 20:41:09 GMT
Hmm, I didn't think the SAMPLE did the same amount of work. The sixth volume of the SQL manual (there are six volumes now? Argh!) has the following statement in it on pg 1-60: ---------------------------------------- Example 2: Using count_description Suppose you want to see if your customers are in at least 100 cities. The SELECT statement to do that is the following: SELECT COUNT (DISTINCT city) FROM (SELECT city FROM customer_table SAMPLE 1000) TEMP ; If customer_table is large, the SAMPLE 1000 clause would not require a full scan of the table and the sort for DISTINCT would only handle 1000 rows. ----------------------------------------- I also did two separate EXPLAINS and got the following differing results: EXPLAIN SELECT OrgCode, AgencyCode FROM Budget;
EXPLAIN SELECT OrgCode, AgencyCode FROM Budget SAMPLE 10;
Seems to be doing something different, although I hate it when the optimizer doesn't return a time estimate. Somebody want to tell me why it doesn't all the time? Did we give up doing that all the time, or is it just a feature that introduces a little randomness in our lives? I taught the advanced SQL class a year ago in Mexico for a client, and at that time there was nothing on what SAMPLE did specifically, but I would think that the PE would tell each amp, hey, send back X records or X percentage of the records (with only one sample that is) that you have. Somebody want to comment? iv Frank C. Martinez IV
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Copyright 2016 - All Rights Reserved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Last Modified: 15 Jun 2023 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||