Press "Enter" to skip to content

Thoughts on Views

Joe Celko shares some thoughts on views, as well as recursive common table expressions:

VIEWs are an undervalued and underused feature in SQL. They basically consist of a query that has been given a name, and a parameter list, so can be used like an inline macro. Technically, you’re supposed to think of it as a virtual table. 

The idea of an inline macro or inline function goes way back to the first versions of Fortran and later BASIC. Depending on the product, the syntax might look like this: FN DOUBLE (N) = (N + N). You had to give the name of the Macro, a simple optional parameter list, assignment operator, usually an =, and the text of the computation. It was often important to put parentheses around the body of the macro, or to have a compiler that would do this for you. 

Read on for the article and a platform-agnostic coverage of views. My problem with views is that developers try to use them to cover a lot of ruin and then they ask why such a simple SELECT * FROM Something query is so slow.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.