The topic is a partial take from another topic.
@The_Doc_Man said: "but the latter method is less efficient"
@ebs17 said: "I would like to contradict that. Both variants work and should produce the same execution plan.
The presence of indexing does not play a role in functionality, but it does play a role in query execution performance (in both cases)."
@The_Doc_Man said: "Depending on indexing, maybe NOT the same plan. Perhaps you don't need an index, but EVERY article I look up to answer the question of whether or not an index is needed says, "In practical terms, yes." (In technical requirements, no.) I.e. you'd be very sorry if you didn't have one.
But the two queries ARE different in one major way. If you look up the "Order of SQL execution" you would find that the JOIN and FROM clauses are processed first, FOLLOWED by any WHERE clauses. The JOIN version reduces the number of records to be processed by the WHERE clause (if any) whereas the non-JOIN version has a Cartesian JOIN set for the WHERE to process. So if there ARE extra criteria for the WHERE clause (in the non-JOIN example), they have more work to do. The WHERE clause in the JOIN example has already had a reduction in the potential size of the return set."
The SQL optimizer determines the actual order using its own algorithms.
Lower efficiency would ultimately result in a longer query runtime. In my own measurements I find approximately the same running times.
When loading table data and before the comparison, you are IN ANY CASE dealing with an instantaneous CROSS JOIN.
Automated import from other database
You appear to be confusing your terminology. You don't join tables with multiple keys. You join tables using fields. The fields may have indexes or be primary / secondary keys (ideally one or both for better performance). I've checked and there is nothing in either of my two data...
www.access-programmers.co.uk
SQL:
SELECT <bunch of fields>
FROM A INNER JOIN B ON ( A.K1 = B.Kappa1) AND ( A.K2 = B.Kappa2 )
WHERE <some criteria>
SQL:
SELECT <bunch of fields>
FROM A, B
WHERE ( A.K1 = B.Kappa1 ) AND ( A.K2 = B.Kappa2 ) AND <some criteria>
@The_Doc_Man said: "but the latter method is less efficient"
@ebs17 said: "I would like to contradict that. Both variants work and should produce the same execution plan.
The presence of indexing does not play a role in functionality, but it does play a role in query execution performance (in both cases)."
@The_Doc_Man said: "Depending on indexing, maybe NOT the same plan. Perhaps you don't need an index, but EVERY article I look up to answer the question of whether or not an index is needed says, "In practical terms, yes." (In technical requirements, no.) I.e. you'd be very sorry if you didn't have one.
But the two queries ARE different in one major way. If you look up the "Order of SQL execution" you would find that the JOIN and FROM clauses are processed first, FOLLOWED by any WHERE clauses. The JOIN version reduces the number of records to be processed by the WHERE clause (if any) whereas the non-JOIN version has a Cartesian JOIN set for the WHERE to process. So if there ARE extra criteria for the WHERE clause (in the non-JOIN example), they have more work to do. The WHERE clause in the JOIN example has already had a reduction in the potential size of the return set."
There can be more criteria expressions in a JOIN clause and a WHERE clause than in the examples shown. In general, these expressions are initially treated equally and a different order may result.If you look up the "Order of SQL execution" you would find that the JOIN and FROM clauses are processed first, FOLLOWED by any WHERE clauses.
The SQL optimizer determines the actual order using its own algorithms.
Lower efficiency would ultimately result in a longer query runtime. In my own measurements I find approximately the same running times.
JOIN and WHERE perform comparisons between field values. For these comparisons, data from the tables, determined by the complete FROM part, must be loaded.The JOIN version reduces the number of records to be processed by the WHERE clause (if any) whereas the non-JOIN version has a Cartesian JOIN set for the WHERE to process.
When loading table data and before the comparison, you are IN ANY CASE dealing with an instantaneous CROSS JOIN.
We all know that a JOIN can also have a duplicative effect. That depends on the real table data.The JOIN version reduces the number of records
Last edited: