Skip to content

Commit

Permalink
merger: don't create key_def/merger for one source
Browse files Browse the repository at this point in the history
A merge source has the same API as merger itself, so there is no
difference in hehaviour between a merger created from one source and
this source itself. However there is no overhead for creating key_def,
merger and passing tuples over the merger.

This opmimization gives me 13% boost on the case from #220.

Follows up #220
  • Loading branch information
Totktonada committed Oct 19, 2021
1 parent d13fe63 commit 99997e1
Showing 1 changed file with 8 additions and 0 deletions.
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

0 comments on commit 99997e1

Please sign in to comment.