From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id B4D06273F8 for ; Mon, 25 Feb 2019 10:45:04 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id djd_srQdCQ7c for ; Mon, 25 Feb 2019 10:45:04 -0500 (EST) Received: from smtp29.i.mail.ru (smtp29.i.mail.ru [94.100.177.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 701F826C49 for ; Mon, 25 Feb 2019 10:45:04 -0500 (EST) Date: Mon, 25 Feb 2019 18:44:59 +0300 From: Kirill Yukhin Subject: [tarantool-patches] Re: [PATCH] sql: re-enable ORDER BY field filter optimization Message-ID: <20190225154459.tl5eoedpcmvepik3@tarantool.org> References: <20190213195252.38092-1-korablev@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190213195252.38092-1-korablev@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: Nikita Pettik 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