Evan
Evan

Reputation: 2635

Constantly sending SQL queries

I don't know if this a common question asked, but if it is, please don't yell at me! :(

I have a Windows Form C# program that executes an UPDATE query every 2 seconds with the threading timer.

My question is: is this dangerous? Will this make my computer run much slower? Am I firing up the CPU usage? I'm a pretty concerned guy when it comes to constantly using something every second.

EDIT: It's UPDATE, not INSERT sorry!

Upvotes: 0

Views: 89

Answers (2)

competent_tech
competent_tech

Reputation: 44961

The answer completely depends on the amount of work the update statement is performing. If it is updating millions of rows every two seconds, then it will definitely impact the performance.

However, if you are only updating a handful of rows (up to say, 100,000) in an SQL Server database, then this frequency should be perfectly acceptable.

The manner in which the update is performed is also important: using cursors, linked servers, CLR functions, databases other than SQL (i.e. Access), and many, many other factors can all significantly impact the performance.

Upvotes: 1

Marc Gravell
Marc Gravell

Reputation: 1063864

This always depends a lot on the size of the operation that is done every 2 seconds; if the operation takes 1.5 seconds to pre-process, execute and post-process, then it will be a problem. If it takes 4ms, probably not. You also need to think about the server; even if we say it takes 4ms, that could be parallelised over 8 cores, so that is 32ms - and if you have 2000 users all doing that every 2 seconds, it starts to add up.

But by itself: fine.

And client-side, on a modern multi-core PC, this is probably not even enough to register as the tiniest blip on the graph.

Upvotes: 2

Related Questions