How inefficient are virtual JOINs tables?

Let's say I have a query like this where I join a series of virtual tables:

SELECT table1.a, tbl2.a, tbl3.b, tbl4.c, tbl5.a, tbl6.a
FROM table1
JOIN (SELECT x, a, b, c FROM table2 WHERE foo='bar') tbl2 ON table1.x = tbl2.x
JOIN (SELECT x, a, b, c FROM table3 WHERE foo='bar') tbl3 ON table1.x = tbl3.x
JOIN (SELECT x, a, b, c FROM table4 WHERE foo='bar') tbl4 ON table1.x = tbl2.x
JOIN (SELECT x, a, b, c FROM table5 WHERE foo='bar') tbl5 ON table1.x = tbl5.x
JOIN (SELECT x, a, b, c FROM table6 WHERE foo='bar') tbl6 ON table1.x = tbl6.x
WHERE anotherconstraint='value'

In my real query, each JOIN has its own JOINs, aggregate functions, and WHERE constraints.

How good / bad would a request like this launch be? . What is the difference in the differences between this and running all the individual virtual tables as your own query and linking the results together outside of SQL?

+5
source share
2 answers

( AFAIK , " " ). , .

, , , . - , , ?

+5

:

SELECT table1.a, tbl2.a, tbl3.b, tbl4.c, tbl5.a, tbl6.a
FROM table1 JOIN table2 on table1.x = table2.x AND table2.foo = 'bar'
            JOIN table3 on table1.x = table3.x AND table3.foo = 'bar'
            JOIN table4 on table1.x = table4.x AND table4.foo = 'bar'
            JOIN table5 on table1.x = table5.x AND table5.foo = 'bar'
            JOIN table6 on table1.x = table6.x AND table6.foo = 'bar'
WHERE anotherconstraint='value';

EDIT:

? ? @Vinko, , , , . , .

+3

All Articles