UnQLite Users Forum

Is JSON Object Search with "db_fetch_all" always linear ?

append delete Mohamed Chit

As far as I understood. It is possible to perform queries using db_fetch_all () and a filter callback function.
The question is, is this always linear search ? UnQLite has to call the user defined filter callback function for each JSON object or there is some optimisation behind the scenes.

For instance MongoDB allows developers to index a collection. I do not see this option in UnQLite. Does it mean there is some optimisation hidden or it is always a linear search O( n ).

If not O( n ), what does UnQLite to speed up the query ?

Best regards

Reply RSS


append delete #1. devel

db_fetch_all() rely on the cursor interfaces: https://unqlite.org/c_api/unqlite_kv_cursor.html which retrieve all the records associated with the given collection and apply a filter callback if any.
Retrieving the data associated with your keys is **O(1)** if the built-in storage engine is used.


(Leave this as-is, it’s a trap!)

There is no need to “register”, just enter the same name + password of your choice every time.

Pro tip: Use markup to add links, quotes and more.

Your friendly neighbourhood moderators: chm_at_symisc, devel_at_symisc