MySQL Forums
Forum List  »  Performance

Re: Performance of Views
Posted by: Roland Bouman
Date: August 19, 2005 03:16AM

I think it has to do with the way MySQL rewrites the query. When you do

SHOW CREATE VIEW

or

SELECT VIEW_DEFINITION


I've observe joins being rewritten to include parentheses; I can imagine this influencing the execution plan, especially when the query has more than one join. An exapmple FROM clause is entered in the CREATE VIEW statement:

from node rn
inner join node dn
on rn.left_node <= dn.left_node
and rn.right_node >= dn.left_node
inner join node an
on dn.left_node >= an.left_node
and dn.left_node <= an.right_node
and an.left_node >= rn.left_node
and an.left_node <= rn.right_node

and this is returned by SHOW CREATE VIEW:

from
(
(`tree`.`node` `rn` join `tree`.`node` `dn` on
(
(
(`rn`.`left_node` <= `dn`.`left_node`)
and (`rn`.`right_node` >= `dn`.`left_node`)
)
)
)
join `tree`.`node` `an` on
(
(
(`dn`.`left_node` >= `an`.`left_node`)
and (`dn`.`left_node` <= `an`.`right_node`)
and (`an`.`left_node` >= `rn`.`left_node`)
and (`an`.`left_node` <= `rn`.`right_node`)
)
)
)

(i inserted some linebreaks to make it a bit more readable)

There are some other issues related to this query rewrite, see:

http://bugs.mysql.com/bug.php?id=12489

and heed the use of the CURRENT_USER function and SELECT * queries on this page
http://mysql.gilfster.com/page.php?parent_id=3&page_id=3.0.2

Options: ReplyQuote


Subject
Views
Written By
Posted
3107
August 15, 2005 05:44PM
1711
August 16, 2005 03:11AM
1618
August 16, 2005 04:32PM
1734
August 18, 2005 05:26AM
1768
August 18, 2005 08:12PM
Re: Performance of Views
1738
August 19, 2005 03:16AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.