Matteo Beccati <[EMAIL PROTECTED]> writes: > Someone on IRC (AndrewSN if I'm not wrong) pointed out that the > restriction selectivity function for <@ is contsel, which returns a > constant value of 0.001. So I started digging in the source code trying > to understand how the default behaviour could be enhanced, and ended up > writing a little patch which adds an alternative containment selectivity > function (called "contstatsel") which is able to deliver better results.
After looking at this a little, it doesn't seem like it has much to do with the ordinary 2-D notion of containment. In most of the core geometric types, the "histogram" ordering is based on area, and so testing the histogram samples against the query doesn't seem like it's able to give very meaningful containment results --- the items shown in the histogram could have any locations whatever. The approach might be sensible for ltree's isparent operator --- I don't have a very good feeling for the behavior of that operator, but it looks like it has at least some relationship to the ordering induced by the ltree < operator. So my thought is that (assuming Oleg and Teodor agree this is sensible for ltree) we should put the selectivity function into contrib/ltree, not directly into the core. It might be best to call it something like "parentsel", too, to avoid giving the impression that it has something to do with 2-D containment. Also, you should think about using the most-common-values list as well as the histogram. I would guess that many ltree applications would have enough duplicate entries that the MCV list represents a significant fraction of the total population. Keep in mind when thinking about this that the histogram describes the population of data *exclusive of the MCV entries*. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org