OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: self-joins in hierarchical queries: optimization problem

From: Sergey Petrunya (psergeyaskmonty.org)
Date: Thu Oct 29 2009 - 11:58:29 CDT


On Thu, Oct 29, 2009 at 07:53:25PM +0300, Sergey Petrunya wrote:
> ... taxonomic_units1 AS O1
> LEFT OUTER JOIN taxonomic_units1 AS O2
> ON O1.tsn = O2.parent_tsn
>
> current optimizer has only one option(*): use Nested-Loops Join algorthm, with
> the outer table being the first one. That is, it will execute these loops:
>
> for each record from O1
> for each record in O2 such that O1.tsn = O2.parent_tsn
> ...
>
> this makes it clear that index on O1.tsn will not be useful. You need indexes
> on parent_tsn column.
I meant, one index over taxonomic_units1.parent_tsn .

BR
 Sergey
--
Sergey Petrunia, Software Developer
Monty Program AB, http://askmonty.org
Blog: http://s.petrunia.net/blog

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql