Comments on: Using Partial and Sparse Indexes in MongoDB https://www.percona.com/blog/using-partial-and-sparse-indexes-in-mongodb/ Sat, 10 Feb 2024 00:44:42 +0000 hourly 1 https://wordpress.org/?v=6.5.2 By: Corrado Pandiani https://www.percona.com/blog/using-partial-and-sparse-indexes-in-mongodb/#comment-10970081 Wed, 19 Dec 2018 15:32:59 +0000 https://www.percona.com/blog/?p=54293#comment-10970081 Yes, you’re right. The important stuff here is that using the index is not the best solution.

]]>
By: Igor Solodovnikov https://www.percona.com/blog/using-partial-and-sparse-indexes-in-mongodb/#comment-10970080 Wed, 19 Dec 2018 15:20:30 +0000 https://www.percona.com/blog/?p=54293#comment-10970080 Corrado, thank you for the interesting post.

I think there is an inaccuracy in interpreting explain results. For the case of the full index you operate following numbers:

200 ms for find({})
350 ms for find( { flag: true } )
10 ms for find( { flag: false } )

But those times are only estimated times from inner stage of the query. (They are in executionTimeMillisEstimate field).

Full query times are (executionStats.executionTimeMillis field):

250 ms for find({})
1028 ms for find( { flag: true } )
83 ms for find( { flag: false } )

That is using index scan to search for {flag: true} is 4 times slower than full table scan.

]]>