R
R
Rifat2017-01-27 11:14:20
SQL
Rifat, 2017-01-27 11:14:20

Is there any difference between such SQL queries?

Request 1
SELECT COUNT(*) FROM TABLE1
Request 2

SELECT COUNT(*) FROM TABLE1 T1
LEFT OUTER JOIN TABLE2 T2
   ON T1.T2_ID = T2.ID
...
LEFT OUTER JOIN TABLEN TN
   ON T1.TN_ID = TN.ID

Those. Do JOINs affect the speed of query execution when counting the number of elements in a selection if they do not participate in conditions?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rsa97, 2017-01-27
@serber

EXPLAIN to help you

D
Dmitry Eremin, 2017-01-27
@EreminD

* (asterisk) implies that you select everything.
So, first, a selection of N tables, and then only the calculation of the results
. Otherwise, what should he count?

A
Anton, 2017-01-27
@MoonMaster

Of course they do. In the first case, you make a selection from one table, in the second case, you link several tables, and in this case the DBMS has to look for the same IDs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question