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.

Recommended Answers

All 2 Replies

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.

Thanks gusano79. I'll see what I can churn out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.