I am trying to verify my understanding of JOINs .
For the following query:
SELECT * FROM tableA join tableB on tableA.someId = tableB.someId join tableC on tableA.someId = tableC.someId;
Does RDMS execute a similar pseudo code as follows:
List tempResults for each A_record in tableA for each B_record in tableB if (A_record.someId = B_record.someId) tempResults.add(A_record) List results for each Temp_Record in tempResults for each C_record in tableC if (Temp_record.someId = C_record.someId) results.add(C_record) return results;
Basically, the more records with the same someId tableA has tableB and tableC , the more records the RDMS scan has? If all 3 tables have entries with the same someId , then, essentially, a full table scan is performed on all three tables?
Do I understand correctly?
source share