nitrite-java icon indicating copy to clipboard operation
nitrite-java copied to clipboard

array index in 4.3

Open catapop84 opened this issue 1 year ago • 1 comments

Just tested your database to see if it's suited to be embedded in our app. We have a collection of users and each user can have one or more email addresses. So we created a field emails as an array of strings

We did a search without index on emails field and with index on emails field and the duration is roughly the same around 170-180ms for a 15k+ documents collection.

Does array index really work because I didn't saw any speed improvements with or without index. Tested also unique vs non unique index and the same result.

If we create a field email of type string (not array) the index works: 30-40ms with index vs 180-190ms without index.

Tested in java , version 4.3 with rocksdb module. The code we did the test is

        long start = System.nanoTime();
        collection.find(where("emails").elemMatch($.eq("[email protected]"))).forEach(System.out::println);
        long end = System.nanoTime();
        Log.info("Time taken: {} ms", (end - start) / 1_000_000);

catapop84 avatar Sep 29 '24 18:09 catapop84

I'll take a look at it.

anidotnet avatar Oct 24 '24 05:10 anidotnet