LooseScan strategy
You are viewing an old version of this article. View
the current version here.
LooseScan is an execution strategy for Semi-join subqueries.
The idea
We will demonstrate LooseScan strategy by example. Suppose, we're looking for countries that have satellites. We can get them using the following query (for the sake of simplicity we ignore satellites that are owned by consortiums of multiple countries)
select * from Country where Country.code in (select country_code from Satellite)
Suppose, there is an index on Satellite.contry_code
. If we use that index, we will get satellites in the order of their ownership:
MariaDB [world]> explain select * from Country where Country.code in (select country_code from Satellite); +----+-------------+-----------+--------+---------------+--------------+---------+------------------------------+------+-------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-----------+--------+---------------+--------------+---------+------------------------------+------+-------------------------------------+ | 1 | PRIMARY | Satellite | index | country_code | country_code | 9 | NULL | 932 | Using where; Using index; LooseScan | | 1 | PRIMARY | Country | eq_ref | PRIMARY | PRIMARY | 3 | world.Satellite.country_code | 1 | Using index condition | +----+-------------+-----------+--------+---------------+--------------+---------+------------------------------+------+-------------------------------------+
Comments
Comments loading...
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.