问题描述:

I'm doing some optimizations and I need some technical help regarding optimization.

Consider the following query :

SELECT *

FROM Employees E

JOIN Data D ON E.idDataType = D.idDataType

WHERE E.idDataType = 1

Does it matter (from optimization point of view) if I filter the parent table or the child table? Which one would be faster?

E.idDataType = 1 VS D.idDataType = 1

Employees:

|idEmployee|Name|Data1|idDataType|AttributeValue2

1 A X 3 xx

2 B T 2 xx

PrimaryKey(idEmployee);

ForeginKey(idDataType) References Data(idDataType);

Data table:

idDataType|Description

1 etc

2 etc

3 etc

4 etc

PrimaryKey(idDataType);

网友答案:

No, it does not matter, the result will be the same. Even if they would have different execution times, the DataBase would take care of that so it will always be executed in the fastest possible way.

The * has probably a greater impact.

相关阅读:
Top