Thank you for this report (if possible, please compress large sample files in the future for faster download).
Your report demonstrates well a limitation of using the current statistics implementation, where better results are obtained with no statistics available (apparently the Doctor creates a new database file with no statistics).
In the current implementation ObjectDB estimates the number of index entries to iterate over, given an exact key, as the number of total entries in the index divided by the number of different keys. ObjectProperty
has 47,581,595 objects and 397,009 different doubleValue
values (keys in the index), about 120 entries per value, so starting with the doubleValue
index on doubleValue
seems reasonable, based on that statistics. This may work well for other values but very bad for doubleValue = 0, as there are 22,134,587 properties with that value.
Your report will accelerate the need to address this issue. Queries are compiled for reuse with different parameters, so usually the exact values are not taken into account during query plan selection. A quick obvious solution could be to follow the worst case, and in this case avoid the doubleValue
index. A more advanced solution should be to use different query plans based on specific provided search values.
As a temporary workaround you can use a query hint to request using the classIdentifier
index for this query, or remove the doubleValue
index, if not needed elsewhere.