MySQL UPDATE Query Hangs

I have a FEDERATED table from another local database from which I have created a VIEW in MySQL, set up as below:

select `wo_line_items`.`work_order_id` AS `work_order_id`,
sum(`wo_line_items`.`quantity`) AS `SumOfquantity`,
sum(`wo_line_items`.`shipped`) AS `SumOfshipped`,
(sum(`wo_line_items`.`quantity`) - sum(`wo_line_items`.`shipped`)) AS `shipped` 
from (`work_orders` join `wo_line_items` on((`work_orders`.`id` = `wo_line_items`.`work_order_id`))) 
group by `wo_line_items`.`work_order_id`,`work_orders`.`status` having ((sum(`wo_line_items`.`quantity`) > 0) 
and (`work_orders`.`status` = _utf8'inspection complete'))

Open in new window

Using this VIEW I am attempting to run an UPDATE query on the local database as follows:
UPDATE wtbl_stages INNER JOIN view_shipped ON wtbl_stages.wo_id = view_shipped.work_order_id SET 
wtbl_stages.stage_date_in = Now(), wtbl_stages.stage_date_out = Now(), 
wtbl_stages.stage_action_id = 3, wtbl_stages.stage_notes = 'Auto Closed by Woksu' 
WHERE (((wtbl_stages.stage_action_id) is null) AND ((wtbl_stages.process_id)= 21) AND (`view_shipped`.`shipped`)=0); 

Open in new window

The query times out after 10 minutes and does not actually appear to run at all.
The view returns a dataset of around 13,000 lines and the udate query is addressing about 19,000 lines.
I am at a loss as to why it hangs. Thanks for reading.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JP_TechGroupAuthor Commented:
I should add that if I run it in Access to which I am connected locally via ODBC, it runs in 5 seconds.
Views are not very good in terms of performance in MySQL as they don't get to use the tables indexes. They kind of scan the result set they produce. Another thing is that I am not sure how can you update a view, if that is what you are trying to do.
Views are have very limited ability to be used for update.  I see at least one problem in that there is a GROUP BY.  Probably other thins as well because there are a lot of restrictions and limitations.

This page from the manual explains them:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
You might want to use EXPLAIN SELECT on the view query to see if it's susceptible of being optimized.  You might also want to consider embedding it into the UPDATE query, instead of keeping it as a view.  That might give you access to the table indexes, and indexed tables will always give better performance.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.