Peter Keller <peter.keller@bvv.bayern.de> writes:
> I generated a table with a column type 'box', inserted some values and
> created an index (ops_box) on that column, run a vacuum and looked with
> the command EXPLAIN if the select will use the index.
> And the result was very astonishing:
> if I had inserted 120000 elements postgres will _NOT_ use the index, if
> I had inserted 100000 elements postgres will use the index!
Hmm. The system's knowledge of selectivities for R-tree indexes is
essentially nil; perhaps someone will be motivated to improve that
someday. In the meantime, the entirely bogus numbers returned by
src/backend/utils/adt/geo_selfuncs.c are supposed to be small enough
to ensure that R-trees are used if available. What was your test
query exactly, and what do you get from EXPLAIN with and without
forcing enable_seqscan off?
regards, tom lane