473,786 Members | 2,407 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

update too slow

Hi,

I need to update 25 * 5000 records, if I do one at the time it takes too
long time, do any one have a good proposal ?

regards

Johnny
Jul 23 '05 #1
7 2621
news.tele.dk wrote:
Hi,

I need to update 25 * 5000 records, if I do one at the time it takes too
long time, do any one have a good proposal ?


If all columns are supposed to have the same value, then just:

update tablename set columnname = newvalue;

If not, then the solution depends on the details, which you didn't yet
tell.
Jul 23 '05 #2
Hi,

This is my sql....

UPDATE BurTabel SET BurOnsketMaengd e = :pOns WHERE BurHalID = :pHID AND
BurFarmID = :pFID AND BurID = :pID;

where the vaules pOns is different and pID i different.

regards
Johnny
"Aggro" <sp**********@y ahoo.com> skrev i en meddelelse
news:J5******** *******@read3.i net.fi...
news.tele.dk wrote:
Hi,

I need to update 25 * 5000 records, if I do one at the time it takes too
long time, do any one have a good proposal ?


If all columns are supposed to have the same value, then just:

update tablename set columnname = newvalue;

If not, then the solution depends on the details, which you didn't yet
tell.

Jul 23 '05 #3
news.tele.dk wrote:
UPDATE BurTabel SET BurOnsketMaengd e = :pOns WHERE BurHalID = :pHID AND
BurFarmID = :pFID AND BurID = :pID;

where the vaules pOns is different and pID i different.


I assume you are running the query from some program.

If so, the options are quite low. But if you got same value for several
rows, you should get some speed gain, if you use

UPDATE BurTabel SET BurOnsketMaengd e = :pOns WHERE BurHalID = :pHID AND
BurFarmID = :pFID AND BurID IN( id1, id2, id2, ... );

Also, if you got same value for majority of rows, you could first update
the value for all rows, and then use single updates to correct the value
from the rest of the rows.
Jul 23 '05 #4
Hi,

your are right, I run the query from Delphi - just for your information.

The problem is, that I must update nearly all the records, so your
suggestion will not work - don't your know some trick to help my speeding
this process up, perhaps a different way to do the same work ?.

"Aggro" <sp**********@y ahoo.com> skrev i en meddelelse
news:6s******** *******@read3.i net.fi...
news.tele.dk wrote:
UPDATE BurTabel SET BurOnsketMaengd e = :pOns WHERE BurHalID = :pHID AND
BurFarmID = :pFID AND BurID = :pID;

where the vaules pOns is different and pID i different.


I assume you are running the query from some program.

If so, the options are quite low. But if you got same value for several
rows, you should get some speed gain, if you use

UPDATE BurTabel SET BurOnsketMaengd e = :pOns WHERE BurHalID = :pHID AND
BurFarmID = :pFID AND BurID IN( id1, id2, id2, ... );

Also, if you got same value for majority of rows, you could first update
the value for all rows, and then use single updates to correct the value
from the rest of the rows.

Jul 23 '05 #5
news.tele.dk wrote:
The problem is, that I must update nearly all the records, so your
suggestion will not work - don't your know some trick to help my speeding
this process up, perhaps a different way to do the same work ?.


Well besides the one I told about, there are two more trics.

First helps if it is possible to get the new value from some other field
or fields. But I guess that is not the case here.

Second requires a bit more work, and your database needs to be offline
while doing it. Dump the content of the whole table into a file or
select all from the table (which would propably be slower) and then
delete all data from your table and create insert queries. Depending how
much data you have, you could perhaps add 500 rows in each query and
then insert 500 rows in each query. Adding 500 rows in one query is much
faster than adding 1 row 500 times, so I assume it would be faster than
updating 1 row at a time.
Jul 23 '05 #6
I think I will try your second suggestion - it will work for my in this
project so that will be fine.

Thx for the help.

Have a nice weekend.

Johnny
"Aggro" <sp**********@y ahoo.com> skrev i en meddelelse
news:6q******** ********@read3. inet.fi...
news.tele.dk wrote:
The problem is, that I must update nearly all the records, so your
suggestion will not work - don't your know some trick to help my speeding
this process up, perhaps a different way to do the same work ?.


Well besides the one I told about, there are two more trics.

First helps if it is possible to get the new value from some other field
or fields. But I guess that is not the case here.

Second requires a bit more work, and your database needs to be offline
while doing it. Dump the content of the whole table into a file or select
all from the table (which would propably be slower) and then delete all
data from your table and create insert queries. Depending how much data
you have, you could perhaps add 500 rows in each query and then insert 500
rows in each query. Adding 500 rows in one query is much faster than
adding 1 row 500 times, so I assume it would be faster than updating 1 row
at a time.

Jul 23 '05 #7
news.tele.dk wrote:
I think I will try your second suggestion - it will work for my in this
project so that will be fine.


Sounds like you have a good solution for this project, and that's good,
but for the record I can think of one more possible solution: use the
CASE function.

UPDATE BurTabel SET BurOnsketMaengd e =
CASE
WHEN :pId BETWEEN 'lowvalue1' AND 'highvalue1' THEN :pOns1
WHEN :pId BETWEEN 'lowvalue2' AND 'highvalue2' THEN :pOns2
WHEN :pId BETWEEN 'lowvalue3' AND 'highvalue3' THEN :pOns3
ELSE :pOnsElse
END CASE
WHERE BurHalID = :pHID AND BurFarmID = :pFID;

This is best if there are a short list of distinct :pOns values, and
that they can be inferred from the :pId values.

Regards,
Bill K.
Jul 23 '05 #8

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

Similar topics

17
14079
by: Felix | last post by:
Dear Sql Server experts: First off, I am no sql server expert :) A few months ago I put a database into a production environment. Recently, It was brought to my attention that a particular query that executed quite quickly in our dev environment was painfully slow in production. I analyzed the the plan on the production server (it looked good), and then tried quite a few tips that I'd gleaned from reading newsgroups. Nothing worked....
1
6172
by: Gent | last post by:
am using FOR UPDATE triggers to audit a table that has 67 fields. My problem is that this slows down the system significantly. I have narrowed down the problem to the size (Lines of code) that need to be compiled after the trigger has been fired. There is about 67 IF Update(fieldName) inside the trigger and a not very complex select statement inside the if followed by an insert to the audit table. When I leave only a few IF-s in the...
6
8649
by: pg | last post by:
Is there any simple way to query the most recent time of "changes" made to a table? I'm accessing my database with ODBC to a remote site thru internet. I want to eliminate some DUPLICATE long queries by evaluating whether the data has been changed since last query. What should I do? -Jason
10
9819
by: Steve Jorgensen | last post by:
Hi all, Over the years, I have had to keep dealing with the same Access restriction - that you can't update a table in a statement that joins it to another non-updateable query or employs a non-updateable subquery. I run across this problem again and again, and yet I've never come up with a single, universal work-around. I'm wondering what other people here are doing.
2
2613
by: info | last post by:
I can successfully open a recordset based upon an Excel sheet in Access, but I can't work out how to copy all the records to an Access table. Any pointers?
2
12132
by: Chris | last post by:
I'm using a DataTable in my application. I am able to load rows into the DataTable quickly. What's puzzling me, however, is that when I update a set of cells in the DataTable, the update is really slow my update code amounts to dataTable.BeginLoadData() dataSet.EnforceConstraints = false tr for(iRowHandle = 0; iRowHandle < iLimit; iRowHandle++
2
3463
by: Kapti | last post by:
Hi! I save 10 rows per second to a Access DataBase. Data are copied to DataSet pro term, then I call Update fuction of DataAdapter to refresh database. code: DataRow newRow; newRow = dataSet.GPS.NewRow(); newRow = distance; newRow = Longitude;
29
2135
by: Geoff Jones | last post by:
Hi All I hope you'll forgive me for posting this here (I've also posted to ado site but with no response so far) as I'm urgently after a solution. Can anybody help me? I'm updating a table on a database i.e. I've modified the table in a DataSet and I want to update it to the SQL database which the table originally came from. I'm using a data adaptor and the update command and it works BUT it is soooooooooo slow!!! Can anybody tell me...
5
8341
by: parwal.sandeep | last post by:
Hello grp! i'm using INNODB tables which are using frequently . if i fire a SELECT query which fetch major part of table it usually take 10-20 seconds to complete. in mean time if any UPDATE qry comes for a perticular row which is part of SELECT qry i want to know that whether UPDATE will wait for completing SELECT qry or not, or it simply executing without bothering SELECT qry .
3
4285
by: traceable1 | last post by:
I installed the SQL Server 2005 SP2 update 2 rollup on my 64-bit server and the performance has tanked! I installed rollup 3 on some of them, but that did not seem to help. I thought it was just a linked server performance issue, but my optimization started running today on one of the "update 2" instances and so far it's been running about 10 hours longer than it normally
0
9492
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10360
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10108
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4064
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.