E
E
Ernest Faizullin2020-11-29 16:46:31
SQL
Ernest Faizullin, 2020-11-29 16:46:31

SQL View vs individual queries with JOIN's?

Does access to SQL View and a specific request with joins differ in terms of resources? (There can be 3-4 joins and plus checks for the sum of values ​​+ checks for emptiness, in short, a complex query)

At first glance, this is the same thing, but
I would like to know if SQL View is just for convenience and beauty, or does it reduce resource usage?

Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
alexalexes, 2020-11-30
@erniesto77

SQL View is used primarily if some users need to provide summary information from tables that are closed to them, excluding access to all columns of the table, or provide only aggregated information (counts, sums, averages), etc., without providing access to the original selection .
To delegate summary data to another user, but not to give the source data - this is just about the view.
In my understanding, there is only one way a view can improve performance. If the sample contains data from rarely changed tables or columns, and the DBMS is able to separately cache the view and it is possible to configure the cache, then you can make fast data sources on views based on rarely changed tables. The most striking example is obtaining a tree structure of an organization with information about the heads of departments. Such a query is burdened with recursiveness, and the data rarely changes. You can make a view from such a request and cache it correctly. And it will become easier, uniform, and possibly more productive to use the organization structure in other queries.

L
Lazy @BojackHorseman, 2020-11-29
SQL

views are not just for beauty, but also do not reduce the use of resources

X
Xeldos, 2020-12-10
@Xeldos

There are materialized views. There are indexed fields of views. But in general, the use of views is not about resources, but about code reuse. To write a ten-level request once, and not get confused in it, but refer to it by a simple name.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question