0

Hi All,

I am running the following query:

UPDATE YFR_Master_Fundraisers SET FRActive=0
WHERE FRNameCode IN (
SELECT FundRaiser
FROM YFR_Master
GROUP BY FundRaiser
HAVING MAX(CollectionDate) < DATE_SUB(CURDATE(),INTERVAL 2 MONTH)
)

It is giving the error described in the subject line. The query seems to be taking too long and timing out. My questions are...

...is there a way to stop it from timing out?

...why is this query taking so long to run? It doesn't look like it should. It updates about two thousand records (in theory), which when running just the select part of the query produces the result immediately.

...is there a way to make it faster?

Thanks for any help offered. It's appreciated greatly as always.

2
Contributors
2
Replies
20
Views
4 Years
Discussion Span
Last Post by Tinnin
0

At first glance, I'd say it's likely that the subquery is what's killing performance. Try executing that SELECT statement separately into a temporary table and doing the update as a JOIN with that table.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.