pub struct Scratch { /* private fields */ }Expand description
The tables a set operation fills in on its way to an answer.
A union walks everything into one table and lets the table be the duplicate check. An accumulating intersection counts into one. Both of those used to be built per call, which is a hash table out of the allocator on a command path, and it is the thing the text rows of the benchmark were mostly spending their time on.
So the tables belong to the caller now. A database keeps one of these and
hands it in, the tables are cleared rather than dropped between calls, and a
SUNION over sets no larger than the last one pays the allocator nothing at
all. The memory that costs is one table as big as the largest union the
database has been asked for, which is smaller than the answer it already had
to build.
setops_small’s union/text/k2 row, nanoseconds per operation over two
text sets of eight members, went from 368.54 to 248.18 when the table
stopped being built per call. That is 1.48 times on a command shaped like
the ones people actually send. The integer rows do not move at all, because
those take the merge plan and never build a table in the first place, which
is the same split the Small work saw from the other side.
It is Default, so a caller that does not care can pass
&mut Scratch::default() and get exactly the old behaviour.