Taco de Wolff
Taco de Wolff

Reputation: 1758

Database advice for indexing on time and location

I'm designing the database for the storage of millions of records of geolocated points and would like to know any advice on how to keep searching the data feasible.

Each record would take approximately 21 bytes of data + 8 bytes for the time and 4+4 bytes for the longitude and latitude. Records would be added constantly while deletes are rare and always in batches. In general, a time based index would have the highest cardinality (i.e. filter out most of the data) and would probably be the primary index. Secondly, the location would be filtered by a rectangle (in WGS84 space) and I presume an Rtree would be a great fit.

Additionally, each record would have an index to a second table of additional information that doesn't change that often. This is about 80 bytes in data and is referenced by an ID (4 bytes) and a time (8 bytes). Again, the time based index would probably be best as a primary, with a secondary index on the ID (Btree?).

I'm thinking that a time-series database would be best (e.g. InfluxDB). However, how would I create a performant secondary index? Surely I can't create that index during a search on the fly. A 3D index of (time,lon,lat) could work (or 2D for the secondary table of (time,id)), but might be fairly heavy / costly? Most of the cardinality is in the time domain, though within a time range the space cardinality is also very high.

Otherwise, perhaps creating a secondary index only within time ranges would be feasible. Most of the searches require a time range of about 3 hours, thus creating a secondary index for each of these ranges (or intervals of 6h/12h/24h) could be done, the primary index would thus return entire ranges that overlap with the requested range, with each having a secondary index.

I guess I'm looking for advice for building an index for time and space that can handle a large number of records coming in every day (millions). Has anyone any experience in this?

Upvotes: 0

Views: 37

Answers (0)

Related Questions