- Direct lookup against subindex
Time: 3.3ms Expression: ft:search($index, $text)/../..
- Lookup against subindex file with reference to large index
Time: 2.9ms Expression: let $s := ft:search($index, $text)/../.. return db:open-id($db, $s/id)/../..
My question is: why would the third expression be slightly faster (or at least not slower) than the second one, if it involves additional computation?
I assume it's due to slight variations during your measurements. How many items will be returned by ft:search? Do you get the same runtime if you run the code 100 or 1000 times?
In the GUI, you can type and execute SET RUNS 100 in the top input bar (in command mode). Your query will then be executed multiple times, and you will get shown the average runtime in the Info View.