PS: Oracle uses the sample function to estimate cardinality for index tuning (Once: ALTER TABLE x ESTIMATE STATISTICS, now done with a procedure). If Derby gets a sample function, it'd be nice to make a tuneup tool that sets cardinality stats based on a sample. Of course, in the case of unique columns, you extrapolate them as unique, in the case of one value, you extrapolate one value, and in between, something appropriately in between!
I think the Oracle sample or something like allowed a dumb sample of the first N rows. One less invasive sample speedup would to be to get N of the first M rows. The sampling user would presumably know something of the randomness of the data sampled, so their time column samples might be low, but others might be uniform. For faster, better samples on really big tables, you really need the block (page) sample, where you can look at n% of the rows in n% of the table scan time!
