The general rule is to decrease the grid sizes as much
as possible to get the finest resolution while minimizing the number
of index entries.
A small value should be used for the finest grid size to optimize
the overall index for small geometries in the column. This avoids
the overhead of evaluating geometries that are not within the search
area. However, the finest grid size also produces the highest number
of index entries. Consequently, the number of index entries processed
at query time increases, as does the amount of storage needed for
the index. These factors reduce overall performance.
Using larger grid sizes, the index can be optimized further for
larger geometries. The larger grid sizes produce fewer index entries
for large geometries than the finest grid size would. Consequently,
storage requirements for the index are reduced, increasing overall
performance.
The following figures show the effects of different grid sizes.
Figure 1 shows a map of land parcels,
each parcel represented by a polygon geometry. The black rectangle
represents a query window. Suppose you want to find all of the geometries
whose MBR intersects the query window. Figure 1 shows
that 28 geometries (highlighted in pink) have an MBR that intersects
the query window.
Figure 1. Land parcels in a neighborhood
Figure 2 shows a small grid size
(25) that provides a close fit to the query window.
The query returns only the 28 geometries that are highlighted,
but the query must examine and discard three additional geometries
whose MBRs intersect the query window.
This small grid size results in many index entries per geometry.
During execution, the query accesses all index entries for these 31
geometries. Figure 2 shows 256 grid
cells that overlay the query window. However, the query execution
accesses 578 index entries because many geometries are indexed with
the same grid cells.
For this query window, this small grid size results in an excessive
number of index entries to scan.
Figure 2. Small grid size (25) on land parcels
Figure 3 shows a large grid size
(400®) that encompasses a considerably
larger area with many more geometries than the query window.
This large grid size results in only one index entry per geometry,
but the query must examine and discard 59 additional geometries whose
MBRs intersect the grid cell.
During execution, the query accesses all index entries for the
28 geometries that intersect the query window, plus the index entries
for the 59 additional geometries, for a total of 112 index entries.
For this query window, this large grid size results in an excessive
number of geometries to examine. Figure 3. Large grid
size (400) on land parcels
Figure 4 shows a medium grid size
(100) that provides a close fit to the query window.
The query returns only the 28 geometries that are highlighted,
but the query must examine and discard five additional geometries
whose MBRs intersect the query window.
During execution, the query accesses all index entries for the
28 geometries that intersect the query window, plus the index entries
for the 5 additional geometries, for a total of 91 index entries.
For this query window, this medium grid size is the best because
it results in significantly fewer index entries than the small grid
size and the query examines fewer additional geometries than the large
grid size. Figure 4. Medium grid size (100) on land
parcels