Archives of the TeradataForum
Message Posted: Tue, 01 Jul 2003 @ 06:38:55 GMT
Subj: | | Re: How to fetch specific number of rows |
|
From: | | McCann, Andy |
I've seen this issue also. If you specify any criteria in your select other than just select * the optimizer will go and derive the whole
dataset and then sample from the spool generated (occasionally it samples twice?) The work around we use is to use a derived table :
sel *
from db.tbl
where condition
and PI_COLUMN in
(select PI_COLUMN from db.tbl sample 5);
This works quite well as it goes and gets the sample rows first, back into the table on the primary index then does any conditions. Of
course, if you are joining tables in the query, it gets even more complicated as you can't possibly expect to get RI. If the view is very
complex then getting this tow work takes some effort.
Cheers
Andy
|