I know the queries utilize more processing, but the connection itself, does it use more RAM than processing?
-
You're incorrect in "knowing" that queries use more "processing". That's not necessarily the case. And how you're expecting us to compare relative amounts of RAM and CPU usage, I'm not sure. Apples vs. Oranges. – EEAA Oct 14 '10 at 23:05
1 Answers
The "connection itself" will use very little of anything relative to the power of modern machines - it is what you do with the connections that makes a difference.
"Queries use more processing" is a misleading simplification. If your queries are well optimised then you will usually find that RAM is key (so the DB server can keep a large working set of data and index pages available for quick searching) followed by I/O bandwidth (so the DB service gets quick responses when it needs to access disk because the data it needs isn't in RAM or when it is writing). After those two then you worry about CPU use as some queries do genuinely need a far amount of CPU umpf to do their work once the data is in RAM to do the work on.
There are overheads in creating a connection, hence the standard recommendation to do as much as you can in one connection rather than dropping and recreating it for every query (which is why most SQL libraries implement connection pooling), but this overhead is not usually CPU, memory or I/O related - it is usually a matter of communication latency (handshakes between client and server, requesting and sending authentication details, the DB service talking to other services like LDAP if authentication is done via them, and so forth).
![](../../users/profiles/5221.webp)
- 22,534
- 42
- 66
-
So what you're saying is if I have more server RAM I can support more MySQL indexes? My server has dual core 2.0 Ghz processors and 4 GB of RAM. I've ordered more RAM but I'm wondering at what point I need to worry about processing... My site got hit with a lot of traffic the other day and ran out of MySQL connections (which is set to unlimited, or as many as the server can support) – Ben Oct 18 '10 at 13:51
-
To see where the bottleneck is when your site gets hit by that sort of traffic you should install a monitoring tool like `collectd` or one of the many other options and have it log memory+swap use, CPU use, I/O rates, and other such metrics. You'll find many monitoring tools have helpful mySQL specific metrics too. – David Spillett Oct 18 '10 at 22:29