472,101 Members | 1,429 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

MYSQL performance issue

Hi,
The following prg keeps cpu usage as 79% always .When i kill/stop the
prg,then cpu comes down.

main()
{
//code for mysql conn
while(1)
mysql_real_query (&mysqlcon, "SET CHARACTER SET 'utf8';", 25);
}

What might be the reason? Wil it be any config issues?

Regards,
sathis

Mar 6 '07 #1
3 2569
kanna wrote:
Hi,
The following prg keeps cpu usage as 79% always .When i kill/stop the
prg,then cpu comes down.

main()
{
//code for mysql conn
while(1)
mysql_real_query (&mysqlcon, "SET CHARACTER SET 'utf8';", 25);
}

What might be the reason?
What do you expect the cpu usage to be when you call a function in a
loop that never ends?
Mar 6 '07 #2
On Mar 6, 2:28 pm, Aggro <spammerdr...@yahoo.comwrote:
kanna wrote:
Hi,
The following prg keeps cpu usage as 79% always .When i kill/stop the
prg,then cpu comes down.
main()
{
//code for mysql conn
while(1)
mysql_real_query (&mysqlcon, "SET CHARACTER SET 'utf8';", 25);
}
What might be the reason?

What do you expect the cpu usage to be when you call a function in a
loop that never ends?
I undertand that cpu usage wil go up for the above prg.
But cld nt understnad, why it goes very high.

Mar 7 '07 #3
kanna wrote:
>What do you expect the cpu usage to be when you call a function in a
loop that never ends?

I undertand that cpu usage wil go up for the above prg.
But cld nt understnad, why it goes very high.
Ok, try this simple example. Raise your hand as quicly as you can and
then lower it as quicly as you can. Now repeat this in endless loop as
fast as you can.

Rasing and lowering your hand is the function. If you repeat this
function in an endless loop without any rest, you should soon find out
that your cpu is turning pretty hot.

If you want to have an endless loop (which is very rare that people
actually want that, unless they don't know what they are doing), you
could add a small rest ( usually done with sleep()-function, but depends
on the programming language ) between the function calls. This would
lower the cpu usage percent dramatically.
Mar 12 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Google Mike | last post: by
10 posts views Thread by Marcus | last post: by
13 posts views Thread by jamie howard | last post: by
reply views Thread by Mike Chirico | last post: by
reply views Thread by Forecast | last post: by
33 posts views Thread by Joshua D. Drake | last post: by
39 posts views Thread by Mairhtin O'Feannag | last post: by
reply views Thread by Sam Flywheel | last post: by

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.