Skip to content
Advertisement

left join taking too long

I have an issue with query performance and cant find out how to fix it.

Both tables have 20k rows

Prod_id like indexes but not primary key because table 1 has duplicates with different month, year etc I need to get table like this (table1 * wh = 80k rows):

I’m using LEFT JOIN to do this but takes too long 15+ mins, any ideas how to improve this query?

Advertisement

Answer

For this query:

You want an index on table2:

You can also include wh2 and any other columns in the select that come from table2.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement