Re: estimating # of distinct values
От | Nathan Boley |
---|---|
Тема | Re: estimating # of distinct values |
Дата | |
Msg-id | AANLkTi=nNLUkMFQKitsSpLTWh+UoT742GcmKtAdsC97U@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: estimating # of distinct values (Florian Pflug <fgp@phlo.org>) |
Ответы |
Re: estimating # of distinct values
|
Список | pgsql-hackers |
>> If you think about it, it's a bit ridiculous to look at the whole table >> *just* to "estimate" ndistinct - if we go that far why dont we just >> store the full distribution and be done with it? > > - the best you could do is to average the > individual probabilities which gives ... well, 1/ndistinct. > That is certainly *not* the best you could do in every case. The mean is only the best estimate in L2, which is definitely not the case here. Consider a table with 10K values, 9,990 of which are 1 and the rest of which are 2, 3, ..., 10, versus a table that has the same 10 distinct values evenly distributed. For a simple equality query, in the first case, a bitmap scan might be best. In the second case, a sequential scan would always be best. This is precisely the point I was trying to make in my email: the loss function is very complicated. Improving the ndistinct estimator could significantly improve the estimates of ndistinct ( in the quadratic loss sense ) while only marginally improving the plans. -Nathan
В списке pgsql-hackers по дате отправления: