From: Sergei Golubchik Date: March 13 2009 11:46am Subject: Re: proposed design for UNION Order By optimization List-Archive: http://lists.mysql.com/internals/36383 Message-Id: <20090313114650.GA9702@janus.mylan> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi, Eric! On Feb 19, Eric Jensen wrote: > On Feb 19, 2009, at 2:33 AM, Sergei Golubchik wrote: >> On Feb 18, Eric Jensen wrote: >> >> You want to create a temporary table with a btree index, put all union >> data into it, and then retrieve rows in the index order ? > > No, not all union data, only the rows necessary for performing the merge, > using the index to select the next top value that determines which > component select to read a new row from next. Ah! Okay, now I understand. > 4. make st_select_lex_unit::exec use k-way merge logic relying on this > one-result-at-a-time fetching to retrive up to LIMIT n results > treating our temp table with its ordered index as a heap Wouldn't it be better to use a heap as a heap, not btree as a heap ? Heap is faster than btree, and MySQL has a heap implementation in mysys/queues.c Regards / Mit vielen Grüßen, Sergei -- __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Sergei Golubchik / /|_/ / // /\ \/ /_/ / /__ Principal Software Engineer/Server Architect /_/ /_/\_, /___/\___\_\___/ Sun Microsystems GmbH, HRB München 161028 <___/ Sonnenallee 1, 85551 Kirchheim-Heimstetten Geschäftsführer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer Vorsitzender des Aufsichtsrates: Martin Häring