Re: BRIN indexes for MAX, MIN, ORDER BY?
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Marti Raudsepp <marti@juffo.org>, Gavin Wahl <gavinwahl@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2015-09-28T15:23:25Z
Lists: pgsql-hackers
On 09/28/2015 05:28 PM, Marti Raudsepp wrote: > Note that Alexander Korotkov already started work in 2013 on a > somewhat similar feature called partial sort: > http://www.postgresql.org/message-id/CAPpHfdscOX5an71nHd8WSUH6GNOCf=V7wgDaTXdDd9=goN-gfA@mail.gmail.com > > In particular, see the 2nd patch for KNN sort -- it uses known > bounding boxes from the GiST index for sorting, which in many ways is > similar to min/max BRIN ranges. > >> *partial-knn-1.patch* >> >> KNN-GiST provides ability to get ordered results from index, but this order >> is based only on index information. For instance, GiST index contains >> bounding rectangles for polygons, and we can't get exact distance to >> polygon from index (similar situation is in PostGIS). In attached patch, >> GiST distance method can set recheck flag (similar to consistent method). >> This flag means that distance method returned lower bound of distance and >> we should recheck it from heap. > > Unfortunatley this work has stalled. No, that was actually committed for 9.5. It's this item in the release notes: > Allow queries to perform accurate distance filtering of > bounding-box-indexed objects (polygons, circles) using GiST indexes > (Alexander Korotkov, Heikki Linnakangas) > > Previously, a common table expression was required to return a large > number of rows ordered by bounding-box distance, and then filtered > further with a more accurate non-bounding-box distance calculation. - Heikki