473,385 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

UPDATE query causes CPU drain

I am new to MySQL, and I have an issue.

I saw this thread on Google,
http://groups.google.com/groups?hl=e...TF-8&threadm=8
g1276%242mog%241%40FreeBSD.csie.NCTU.edu.tw&rnum=1 0&prev=/groups%3Fhl%3Den%2
6lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8%26q%3DMySQL%2BUPDATE%2Bslow, that
describes my problem exactly.

I am updating a table in Java via JDBC, and it throws MySQL into an infinite
loop that consumes 100% CPU time.

MySQL SERVER: 4.0.17-nt

The query:
UPDATE prices
SET 1_mo=1.1, 3_mo=1.2, 6_mo=1.3, 1_yr=1.4, 5_yr=1.5, 10_yr=5.3
WHERE dms_ticker='GE' AND date='2003-12-31';

I do repeat this thousands of times via a for loop, where each of the
inserted values is individually calculated.

the prices table looks like:
mysql> show columns from prices;
+-----------------+------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+------------+------+-----+---------+----------------+
| id | int(11) | | PRI | NULL | auto_increment |
| dms_ticker | varchar(5) | YES | | NULL | |
| dms_security_id | int(11) | YES | | NULL | |
| date | datetime | YES | | NULL | |
| open | double | YES | | NULL | |
| close | double | YES | | NULL | |
| adj_close | double | YES | | NULL | |
| high | double | YES | | NULL | |
| low | double | YES | | NULL | |
| volume | double | YES | | NULL | |
| 1_mo | double | YES | | NULL | |
| 3_mo | double | YES | | NULL | |
| 6_mo | double | YES | | NULL | |
| 1_yr | double | YES | | NULL | |
| 5_yr | double | YES | | NULL | |
| 10_yr | double | YES | | NULL | |
| score | int(11) | YES | | NULL | |
+-----------------+------------+------+-----+---------+----------------+

Is this a known issue in 4.0.17? Is there a better way for me to accomplish
this?

Thanks in advance,

Tim
Jul 19 '05 #1
3 1654
Tim Fullerton wrote:
I do repeat this thousands of times via a for loop, where each of the
inserted values is individually calculated.


This will be very slow. Are you sure your MySQL hangs? It could be just
doing it's job.

Can you try to do the same with few hundred inserts, then perhaps a
thousand, etc. Find out how the execution time increases and see if you
can find any critical points when execution time seems to increase to
infinite.

You should also check how long does it take for MySQL to commit one
update command. If one update takes for example 2 seconds, then updating
5000 rows would take about 2,7 hours.
Jul 19 '05 #2
Tim Fullerton wrote:
I do repeat this thousands of times via a for loop, where each of the
inserted values is individually calculated.


This will be very slow. Are you sure your MySQL hangs? It could be just
doing it's job.

Can you try to do the same with few hundred inserts, then perhaps a
thousand, etc. Find out how the execution time increases and see if you
can find any critical points when execution time seems to increase to
infinite.

You should also check how long does it take for MySQL to commit one
update command. If one update takes for example 2 seconds, then updating
5000 rows would take about 2,7 hours.
Jul 19 '05 #3
Tim Fullerton wrote:
I do repeat this thousands of times via a for loop, where each of the
inserted values is individually calculated.


This will be very slow. Are you sure your MySQL hangs? It could be just
doing it's job.

Can you try to do the same with few hundred inserts, then perhaps a
thousand, etc. Find out how the execution time increases and see if you
can find any critical points when execution time seems to increase to
infinite.

You should also check how long does it take for MySQL to commit one
update command. If one update takes for example 2 seconds, then updating
5000 rows would take about 2,7 hours.
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Joshua Moore-Oliva | last post by:
I have a query that is asking me to GROUP a column, yet when I GROUP it it causes an error near GROUP. What is very strange about the following query is that the line list_size_active =...
3
by: Greg Strong | last post by:
Hello All, Is the only solution to an update query which requires the records in a certain order to dump the records into a temp table in the required order, then do the update query? I've...
0
by: Metal2You | last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that accesses a Sybase database back end. We're using Sybase SQL Anywhere 9.0.2.3228. I have installed and registered the Sybase...
2
by: mark | last post by:
I have come across a problem that has me baffled. I am using PHP with MySQL 4.1.14. Whenever I execute an update statement against a specific table, some of the varchar fields do not get set to...
12
by: si_owen | last post by:
Hi all, I have a SQL query that worked fine in my project until it came to testing. I found that the NvarChar fields I have wont accept the use of an ' My code and query is here does anyone...
2
by: Reedsp | last post by:
OS: MS XP Access version: 2003 SP2 I am trying to use an update query to replace quote marks with nothing. In essence, I'm removing quote marks. I get a error message when a field is empty or...
2
by: eggie5 | last post by:
I have some code (C#) that runs an SQL update query that sets the value of a column to what the user passes. So, this causes an error when anything the user passes in has a ' character in it. I'm...
6
by: Nano | last post by:
I want to update a MS Access Table using ASP, I have made the connection with the database but I am unable to update it. I am using the following code: ...
5
by: Chris Cowles | last post by:
I use an application that uses Oracle 8.1.7. All functions of the application are completed with calls to stored procedures. A data entry error occurred that caused thousands of records to be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.