Hi,
I've got a query which totals a customers spending from the transactions table and then updates a field in the client table with the total value previously calculated.
The query looks like this:
update CLIENT c1
SET c1.field_1 = (select sum(tr.credit) from CLIENT c2 inner join
transactions tr on (c2.toro_clientid = tr.toro_clientid)
WHERE c2.toro_clientid = c1.toro_clientid)
The only problem is that when you run the query it takes in excess of 25 minutes to complete. I am running the query on the local server so there's no network involved. There is approx 12000 records in the client table and 6000 in the transactions table. There is an index on the fields making up the join.
I have to run this query on 65 different imported data sets so you can see why I need to speed this up!!
Why does this run so slowly?
Any help would be GREEEAATLY appreciated!!!!
Cheers
Paul
I've got a query which totals a customers spending from the transactions table and then updates a field in the client table with the total value previously calculated.
The query looks like this:
update CLIENT c1
SET c1.field_1 = (select sum(tr.credit) from CLIENT c2 inner join
transactions tr on (c2.toro_clientid = tr.toro_clientid)
WHERE c2.toro_clientid = c1.toro_clientid)
The only problem is that when you run the query it takes in excess of 25 minutes to complete. I am running the query on the local server so there's no network involved. There is approx 12000 records in the client table and 6000 in the transactions table. There is an index on the fields making up the join.
I have to run this query on 65 different imported data sets so you can see why I need to speed this up!!
Why does this run so slowly?
Any help would be GREEEAATLY appreciated!!!!
Cheers
Paul