Is a MySQL view faster than a normal query?

后端 未结 2 1720
栀梦
栀梦 2021-02-11 18:04

I have a complex query using many joins (8 in fact). I was thinking of simplifying it into a view. After a little research I can see the benefits in simplicity and security. But

2条回答
  •  不要未来只要你来
    2021-02-11 18:53

    A view's basically a stored subquery. There's essentially no difference between:

    SELECT *
    FROM someview
    

    and

    SELECT *
    FROM (
        SELECT somestuff 
        FROM underlying table
    );
    

    except the view's a bit more portable, as you don't have to write out the underlying query each time you want to work with whatever data it returns.

提交回复
热议问题