Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merger: don't create key_def/merger for one source #226

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions crud/select/merger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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&'.
Expand Down