I have got a database with 50 millions of documents, they are similar to:
{
"type": "s",
"uid": 1,
"time": 1575168010,
"hash": "eb5438b8c884fafed6777a66bd2124bedc879d2df194d453fcb910443433b912",
"value": 854.3038
}
RAM USED 6 GB, Disk Used 12 GB.
The following query takes 90 seconds:
CREATE INDEX `adv_time_value_type` ON `bucket`(`time`,`value`) WHERE (`type` = "s")
SELECT SUM(value) / COUNT(value) FROM `bucket` WHERE type == "s" AND time > 0
-- PLAN: Index scan - PROJECT.
I have tested on Postgresql on the same machine. It takes 3 seconds on the same number of rows. Without any index.
Maybe I am missing something, it’s 30x slower on a literally simple structure and simple query.