'Tables vs Views : Network speed?

At the moment my application uses an ORM to handle DB Queries. However, when I activated the DB logs, I noticed that it uses multiple queries for joining and fetching simple data such as using the username instead of the user id, filtering on a related table etc.

This leads to the ORM running almost 4-5 queries for a single lookup and thus when loading certain pages (with multiple API calls) it easily runs into 30-35 queries.

I'm planning on creating SQL Views to fetch queries with simple joins so that it can reduce the no of network round trips required when processing a single request.

Considering that the product is in its pre-alpha stage, is this premature optimisation or can this actually provide a faster user experience?



Solution 1:[1]

Using a view is quite fine, but if you end up having one view per join your application needs, that could end up being a large number of views. I would explore the capabilities of your ORM some more, and if it truly is not able to generate joins, I would recommend using different software.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Laurenz Albe