diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cb7495d..81735362 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. testing. It means that methods `crud.min()` and `crud.max` won't work for old versions (< 1.10.8) anymore. * Names of errors generated by CRUD operations have been unified. +* Opmimize `crud.select()` / `crud.pairs()` for one replicaset case (say, when + `bucket_id` is passed or deducible from conditions). It gives 13% boost on + the case from #220. ### Fixed diff --git a/crud/select/merger.lua b/crud/select/merger.lua index 66b6e19e..fa443b84 100644 --- a/crud/select/merger.lua +++ b/crud/select/merger.lua @@ -163,6 +163,14 @@ local function new(replicasets, space, index_id, func_name, func_args, opts) table.insert(merger_sources, source) end + -- Trick for performance. + -- + -- No need to create merger, key_def and pass tuples over the + -- merger, when we have only one tuple source. + if #merger_sources == 1 then + return merger_sources[1] + end + local keydef = Keydef.new(space, opts.field_names, index_id) -- When built-in merger is used with external keydef, `merger_lib.new(keydef)` -- fails. It's simply fixed by casting `keydef` to 'struct key_def&'.