I have 2 tables in mySQL db... they are very large.. its about 1 million now and soon to be 5 million or so
one is jobseeker other is joomla users table
I want to copy or insert IDs into the jobseeker table where the email column of both matches..
i.e. jobseeker email = jos users email.
I used below query but it takes too much time and puts heavy load on mysql server ....the queries gets stuck and i always end-up restarting mysql ...
UPDATE `jos_jbjobs_jobseeker`
SET user_id = ( SELECT jos_users.id
FROM jos_users
WHERE jos_users.email = jos_jbjobs_jobseeker.email)
WHERE EXISTS
( SELECT jos_users.id
FROM jos_users
WHERE jos_users.email = jos_jbjobs_jobseeker.email);
how can I optimize above query to achieve better performance. Also, I would be interested if it can be executed in batches i.e 20000 or 40000 records at time.
Please advise
Try this:
UPDATE
jos_jbjobs_jobseeker a
INNER JOIN jos_users b ON a.email = b.email
SET
a.user_id = b.id
How about this simple query?
UPDATE jos_jbjobs_jobseeker jjj
JOIN jos_users ju
ON jjj.email = ju.email
SET jjj.user_id = ju.id;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With