[tarantool-patches] Re: [PATCH] sql: re-enable ORDER BY field filter optimization

Kirill Yukhin kyukhin at tarantool.org
Mon Feb 25 18:44:59 MSK 2019


Hello,

On 13 Feb 22:52, Nikita Pettik wrote:
> When we replaced SQLite's ephemeral spaces with our ones, one
> optimization concerning ORDER BY clause was disabled. It allows to
> reduce number of fields in format of ephemeral space or sorter table.
> To illustrate how it works, consider example:
> 
> CREATE TABLE t (id INT PRIMARY KEY, b INT);
> SELECT * FROM t ORDER BY b;
> 
> To sort entries from t, ephemeral space with format [b, id, b] is
> created. One can see, that such format contains duplicate of b column.
> To avoid such situation, SQLite provides optimization which removes
> duplicates. Meanwhile, it doesn't change already set format of ephemeral
> (or sorter) space (and SQLite tolerates that format difference). That's
> why it was turned off. However, such optimization turns out to be not
> optional but required: some column values shouldn't be computed twice.
> For instance:
> 
> SELECT random() AS x FROM t ORDER BY x;
> 
> Without filtering fields from ephemeral space format, it would be like:
> [random(), random()]. In other words, results would be sorted by first
> call to random() function, but resulting set would consist of values
> given by second call of random(). So, to enable it, we should reduce
> field count in format of ephemeral space by number of matches between
> SELECT and ORDER BY column lists.
> 
> Also, type of return value for random() function has been fixed.
> 
> Closes #3783
> ---
> Branch: https://github.com/tarantool/tarantool/tree/np/gh-3783-enable-field-filter-order-by
> Issue: https://github.com/tarantool/tarantool/issues/3783

I've checked your patch into 2.1 branch.

--
Regards, Kirill Yukhin




More information about the Tarantool-patches mailing list