Please can you help me, I am getting this exception
Lock wait timeout exceeded; try restarting transaction
and I'm running this query.
UPDATE Table1 INNER JOIN Table2
SET Table1.xCoord = Table2.Longitude, Table1.yCoord = Table2.Latitude,
Table1.location2 = CONCAT(Table2.Street, ', ', Table2.Post_Town, ', ',
Table2.County, ', ', Table2.Postcode, ', UK ')
WHERE (Table1.location2 = '' OR Table1.location2 IS NULL) AND
(Table1.location1 LIKE CONCAT('%', Table2.Street, '%'))
AND (Table2.location1 LIKE CONCAT('%', Table2.Post_Town, '%'));
Table2 is 30 million rows and table 1 is 4000 rows (likely to increase). I have an index on 1. street 2. town. In reply to Rick Ive given example tables.
- Table 1
| location 1 || location 2 || postcode
|| flat 30 234 harddrive street morganvale ||(new string add)||
- Table 2
|| house no || street || town || postcode || xcoord || ycoord ||
|| 234 || harddrive street|| morganvale|| mr12 123 || 5.1234 || 24.2345||
and I'm matching the street name and town using the LIKE pattern. The commas have been removed and location1 is all lowercase.
I'm using AWS and have 100GB storage in order to increase write speeds and I'm using a t2.small with 2GB of RAM.
My question is that can this query be made to run faster and how do I prevent the lock wait timeout exception. Is the query correct?
The aim of the query is to add x and y coordinates and a location to table1 from a 30 million file in table2.
Ive been thinking of some alternatives? will postgre postgis run this query faster than mysql. What about tackling this joining of tables from an application such as java.