Nobody stops you from creating multiple indexes - each index can help with certain queries.
If I were you, I would create at least following two indexes:
CREATE INDEX events_1_ix ON Events(TimestampTicks,TelemetryId);
(one that you have been using), and
CREATE INDEX events_2_ix ON Events(TelemetryId);
SQLite can make use of these indexes in following situations:
- Search when
TimestampTicks
andTelemetryId
are provided (1st index) - Search when
TimestampTicks
only is provided (also 1st index) - Search when
TelemetryId
only is provided (2nd index)
If you only create separate indexes for TimestampTicks
and TelemetryId
, that will keep options 2 and 3 fast, but option 1 will become unavailable .
You can create as many indexes as you want, but remember that index maintenance does not come for free. First, it will take more disk space - it is not uncommon for an index to occupy 10%-30% of table size. So, if you create too many indexes, their total size might exceed usable table size. Also, when there are many indexes, insert or update speed can become much slower than without them.
Regarding your original statement that SQLite can use only one index per query - this is not quite correct.
Correct statement is that SQLite can only use one index per table in given query. If your SQL joins more than one table, each table can make use of an index that gives best performance to access that table.