Performance tips¶
Advanced Spatial index performance varies depending upon several factors regarding to the use case and you should probably do some tuning work. However, there is some general advice.
Take a look to performance tips at Apache Ignite's official documentation.
Affinity collocation¶
You can route any search to a certain cache's (affinity) key/s, in such a way that only a
subset of the cluster nodes will be hit, saving precious resources when you have PARTITIONED
caches with billions of entries in a cluster with hundred of nodes.
Example : Affinity keys on SQL clauses
Below query will route search to the UNIQUE node that contains the primary cache's partition for countryCode = 'ES'
. Remember that countryCode
is the tweet's affinity key.
Pay attention to index hint on SQL query: USE INDEX(tweet_place_idx)
, this ensures that SQL query optimizer uses tweet_place_idx
spatial index and not another to run the query.
To make sense this query, assume that geographical position (latitude: 40.416775, longitude: -3.703790)
is within Spain countryCode = 'ES'
.
-- Affinity key condition line is highlighted SELECT ID, BODY, PLACE, PUBLIC.ST_DISTANCE_SPHERE(place, 'POINT (-3.703790 40.416775)')/1000 as distance_km FROM "tweets".tweet USE INDEX (tweet_place_idx) WHERE place && public.ST_GEOCIRCLE('POINT (-3.703790 40.416775)', 6000) and PUBLIC.ST_DISTANCE_SPHERE(place, 'POINT (-3.703790 40.416775)') <= 6000 and countryCode = 'ES' order by distance_km desc limit 100;
+------+------------------------------------+------------------------------------------------+-------------------+ | ID | BODY | PLACE | DISTANCE_KM| +======+====================================+================================================+===================+ | 8378 | big data gives organizations 8378 | POINT (-3.772904879942281 40.421784009278184) | 5.877374868190893| +------+------------------------------------+------------------------------------------------+-------------------+ |37155 | big data gives organizations 37155 | POINT (-3.6380660941530323 40.42141155416504) | 5.587711868859234| +------+------------------------------------+------------------------------------------------+-------------------+ |58808 | big data gives organizations 58808 | POINT (-3.729606286597199 40.37173141817499) | 5.464997075063737| +------+------------------------------------+------------------------------------------------+-------------------+ |77380 | big data gives organizations 77380 | POINT (-3.706806844939874 40.36775414863283) | 5.45686194450224| +------+------------------------------------+------------------------------------------------+-------------------+ |12933 | big data gives organizations 12933 | POINT (-3.6649634836220173 40.451800390063305) | 5.095776716778619| +------+------------------------------------+------------------------------------------------+-------------------+ |49273 | big data gives organizations 49273 | POINT (-3.7104281499138283 40.37563441659352) | 4.609040190217024| +------+------------------------------------+------------------------------------------------+-------------------+ |10044 | big data gives organizations 10044 | POINT (-3.7436340044866285 40.399516380751784) | 3.8812000456430584| +------+------------------------------------+------------------------------------------------+-------------------+ |56307 | big data gives organizations 56307 | POINT (-3.66013803142915 40.40659292511337) | 3.8653120435493484| +------+------------------------------------+------------------------------------------------+-------------------+ |69222 | big data gives organizations 69222 | POINT (-3.7266549086214713 40.43754064232654) | 3.0128789379494414| +------+------------------------------------+------------------------------------------------+-------------------+ | 8580 | big data gives organizations 8580 | POINT (-3.728757264872743 40.41049598199824) | 2.2261074062240658| +------+------------------------------------+------------------------------------------------+-------------------+
Use the latest version¶
Each new version might be as fast or faster than the previous one, so please try to use the latest version if possible. You can find the list of changes and performance improvements at release notes.
Use a separate disk¶
You will get better performance using a separate disk for the spatial index files.
Hawkore's Advanced Spatial Index is stored, when persistence is enabled, on a well known directory structure. You can mount desired path on separate disks.
IGNITE_WORK_DIRECTORY └── db └── spatial └── cache-CACHE_NAME (per cache name) └── SPATIAL_INDEX_NAME (per spatial index name) ├── s_0 (per degree # of parallelism) ├── ... └── s_(#-1)