MySQL Forums
Forum List  »  Newbie

MYSQL update taking to long need help
Posted by: Martin Weaver
Date: January 30, 2017 08:38AM

Ok being fairly new to this i am going to try to make this as clear as i can. Please bear with me.

I have two table one is called phase3 the other is called cqt.

phase 3 has the following columns: num (not null auto increment), stored (decimal not null), linking (int foreign key (schema1.cqt(trayid)) not null), trayid (int zero fill), pallet (int zero fill)

cqt has the following columns: trayid (int primary key not null), trayact (int not null), traytype (varchar(5)), pallet (int not null)

Phase3 has 995,865 records in it

cqt has 1270 records in it.

trayid from cqt is unique and has a 1 to about 160 reference to linking in phase3. which is why i made trayid primary and linking foreign and the two are referenced.

So now i am trying to find a way to make the fastest query possible that will take the trayact and pallet from cqt and update phase3 with these values.

And right now the fasted query i have done takes about 18min to run

That query would be

update schema1.phase3 as a right join schema1.cqt as b on b.trayid = a.linking set a.trayid = b.trayact, a.pallet = b.pallet

so do i have the foreign and primary keys mixed? or do i have a wrong type update query? or am i just hampered by the size of the table? or maybe something else. looking for whatever assistance i can come up with.

Thank you.

Regard
Martin

Options: ReplyQuote


Subject
Written By
Posted
MYSQL update taking to long need help
January 30, 2017 08:38AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.