user1433877
user1433877

Reputation: 145

Converting Oracle SQL join query into MySQL query

Given the following join in Oracle Pl/SQL:

select a.field1, b.field1, b.field2
from table_a a, table_b b
where a.field2 = b.field3;

When executed this code in MySQL, it takes a really long time to do the task while in Pl/SQL it takes no time. The tables are the same in the two environments. No fields are indexed.

Is there a difference between the joins in the two dialects? What would be the correct translation of this in standard SQL?

Upvotes: 2

Views: 420

Answers (2)

FSP
FSP

Reputation: 4827

You need indexes in MySql to avoid the problem that you are facing.

Upvotes: 0

usr
usr

Reputation: 171178

MySQL does not cope with having no indexes. Oracle can do a hash join and still be fast. Add indexes on the join columns.

Upvotes: 1

Related Questions