CPU and Memory Usage: Connect and disconnect

Support/Development for MySQL, MariaDB, and other database systems
vdTOG
New Forum User
New Forum User
Posts: 4
Joined: Sat Feb 13, 2016 10:45 pm
Location: Brazil

CPU and Memory Usage: Connect and disconnect

Unread post by vdTOG »

I'm having problems with consumption of the CPU and the memory.
What of these options would help me to consume less?


Option #1
Connect to sql server, execute the sql command and disconnect once it is done. And do again for each command.

Option #2
Connect to sql server, execute all the sql commands and disconnect when script dies.


More ideas will be very appreciated.

Thank you
prupert
Forum Regular
Forum Regular
Posts: 573
Joined: Tue Aug 01, 2006 2:45 pm
Location: Netherlands

Re: CPU and Memory Usage: Connect and disconnect

Unread post by prupert »

Using a single connection will most likely be more efficient.

However, if you keep the connection open for a long time, without really using it, you will be wasting a tiny bit of memory and an otherwise available connection slot on the database server. If you have a huge amount of concurrent requests this can become an issue.
Lemonbit Internet Dedicated Server Management
Post Reply