Table one: 35 million records
Table two: 1,6 million records
I’m executing an update query in table one based upon 3 equalities. Both tables are pure data colls without any keys.
`UPDATE table1,table2
SET table1.TravelTime=table2.CongestionTime
WHERE table1.From = table2.From
AND table1.To = table2.To
AND table1.Time= table2.Time`
Yet this operation seems to be doomed to be slow. Is there a way to be creative to speed up this process?
Currently a query is running at a mere 300 updates/second suggesting it would take 33 hours to complete this query.
I think you just said it there. You need indexes to get good performance when working with this amount of data.
Try adding multi-column indexes:
(From, To, Time)for Table1.(From, To, Time, CongestionTime)for Table2.You may also want to consider if it is appropriate to add a foreign key constraint.
Related documentation