Randolph West doesn’t mince words:
Nested views are bad. Let’s get that out of the way.
What is a nested view anyway? Imagine that you have a
SELECT
statement you tend to use all over the place (a very common practice when checking user permissions). There are five base tables in the join, but it’s fast enough.Instead of copying and pasting the code wherever you need it, or using a stored procedure (because for some reason you’re allergic to stored procedures), you decide to simplify your code and re-use that
SELECT
in the form of a database view. Now whenever you need to run that complicated query, you can instead query the view directly.What harm could this do?
Spoilers: a lot.