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
It can sometimes help, but it's no silver bullet. I've seen a view help performance, but I've also seen it hurt it. A view can force materialization, which can sometimes get you a better access path if MySQL isn't choosing a good one for you.
No, a view is simply a stored text query. You can apply WHERE
and ORDER
against it, the execution plan will be calculated with those clauses taken into consideration.
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.