I
I
Ivan Nikolaevich2014-04-22 22:23:06
PHP
Ivan Nikolaevich, 2014-04-22 22:23:06

What is the best way to create a request to the database: sculpt one big one or produce small ones?

There is a SQL server base with a couple of dozen tables.
For one of the tasks of the interface, it is required to select a large piece of data from 8 tables at once. Moreover, the operation is one-time and quite rare.
What is the best way to make a request?
Do a large selection with a dozen subqueries and all sorts of JOINs, or is it better to do a dozen separate SELECTs?
PS I'm new to SQL and, like many programmers, I suffer from premature optimization.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Bogdan Odarchenko, 2014-04-22
@north_leshiy

Here the question is in speed and my own choice, I tested that a single SQL query is faster and broken into successive iterations, in both cases I won sequential + they were less gluttonous to resources.
You can always test it yourself, and understand what is faster, I voiced my opinion -)
Fill in your structure with 10,000,000 additional. records and compare.
Right or wrong is a difficult question.

M
Mandor, 2014-04-23
@Mandor

If the task allows - do a few small ones, it's easier and more convenient. Another thing, if you need filtering / sorting by the fields of join tables, then there is no choice.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question