Bluehost.com Web Hosting $6.95

update is taking over 30 hours

This is a discussion on update is taking over 30 hours within the MySQL Database forums, part of the Database Forums category; I've got to update a table with data from other table. I calculated the cost of all our products ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-08-2007
Carlos Troncoso
 
Posts: n/a
Default update is taking over 30 hours

I've got to update a table with data from other table.
I calculated the cost of all our products and services (over 500,000.-
rows) and I need to apply the cost to each and every transaction (7.5
million rows) for the year 2006.

One table is the transaction, which is partitioned using year as the
range and is indexed in on both where conditions.
The second table is costs, and is indexed as well.

The update is taking forever... it's been running for 30 hours and I'm
starting to think it's stuck or something else. Even though the
process list says "sending data"

The EXPLAIN and EXPLAIN PARTITIONS of the equivalent select seems ok,
there is enough disk space... enough temp space... don't know what's
happening.

I'm using this statement:
/*------------------------------------------*/
UPDATE `ctacte_f_costo`, `costoporcodigo`
SET
`ctacte_f_costo`.`costo` =
(`costoporcodigo`.`costo`*`ctacte_f_costo`.`CANT`) ,
`ctacte_f_costo`.`procesado`= 1
WHERE
`costoporcodigo`.`tipo` = `ctacte_f_costo`.`TIPOPR` and
`costoporcodigo`.`codval` = `ctacte_f_costo`.`CODVAL` and
`ctacte_f_costo`.f_movfis between '2006-01-01' and '2006-12-31';
/*------------------------------------------*/

I'm considering if this other sintax might be faster

UPDATE `ctacte_f_costo`
SET
`ctacte_f_costo`.`procesado`= 1,
`ctacte_f_costo`.`costo` = (
SELECT
t1.`costo`*`ctacte_f_costo`.`CANT` as costo
FROM
`costoporcodigo` t1
WHERE
t1.`tipo` = `ctacte_f_costo`.`TIPOPR` and
t1.`codval` = `ctacte_f_costo`.`CODVAL`)
WHERE
`ctacte_f_costo`.f_movfis between '2006-01-01' and '2006-12-31';


Any advice is welcome... (please, the idea is ADVICE... please no "why
do you want to do that" or other replies that don't answer.
Please remember that this question might be asked by other ppl and the
idea is finding answers.. not more questions.
THX

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 04:53 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0