U
U
user_of_toster2022-01-24 07:54:21
Database design
user_of_toster, 2022-01-24 07:54:21

10-15 joins in one request - an antipattern?

Is 10-15+ joins within a single query a sign of bad database design or a bad choice in favor of relational databases in general? Or is this the norm for relational databases?

The speed of requests, although not the fastest, is still satisfactory, but the kilometric request is doubtful. I didn’t work closely with other databases, except for relational ones, but something tells me that there is a solution that 1) will shorten kilometric unreadable queries; 2) optimizes execution time

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Konstantin Tsvetkov, 2022-01-24
@user_of_toster

will shorten kilometer-long unreadable queries
Use macros, ugh, views.
optimizes execution time
Use stored, ugh, indexed views. And stored, precisely, calculated fields.
This is for simultaneous 1+2. For the rest - another question with the text of the request (for the picture - etsih with nails) and the tag Оптимизация SQL-запросов.
Oh, and if you have it for reports or analytics, then you should look at OLAP .

V
Vladimir Korotenko, 2022-01-24
@firedragon

why do you need so much data?
If for analytics, then the norms. And if for simple lists something went wrong

A
Adamos, 2022-01-24
@Adamos

You can't analyze code without asking yourself the question "why"?
If the data is really complexly connected and there is no way without these joins, then the point is not in the request, but in the task or architecture.
And if the joins are mixed, just to make one instead of five requests, and they are easily separated - it makes sense to compare both options, perhaps this is an attempt at "human" optimization, which actually only prevents the database from caching frequently requested data.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question