Simultaneous query on the same connection?
I am currently modifying my C# application and was thinking of following this for the MySQL part of it:
- Server get called to process any information
- Server initiate MySQL connection
- Server do all queries and commands needed (possible to happen simultaneous queries ?)
- MySQL connection stays idle after number 3 finish for 5 minutes
- In case a new request begins within the 5 minutes from number 4, start the 5 minutes counter from 0 when the last request ends
- MySQL connection closes
- Starts from 2
I few doubts I was having in regards this were:
Will a single connection allow me to run simultaneous queries/commands (weird question I know, I haven't hit开发者_运维问答 a simultaneous connection yet and am not sure how to test it) ?
I was initially thinking of using connection pooling but since I may have some queries that would take some time to finish, I opted for not, so I can keep sending commands and get their reply while the connection is open, is that OK ?
If instead of using the above sequence I simple open and close connections per command, it could happen that the application hits the max connection limit of that MySQL user is that correct ? if I am not mistaken there is a cap to 100 connections.
Will a single connection allow me to run simultaneous queries/commands
No.
I was initially thinking of using connection pooling but since I may have some queries that would take some time to finish, I opted for not, so I can keep sending commands and get their reply while the connection is open, is that OK ?
Yes, that's perfectly OK, keep an eye out for locks, if you are also doing updates though.
If instead of using the above sequence I simple open and close connections per command, it could happen that the application hits the max connection limit of that MySQL user is that correct ? if I am not mistaken there is a cap to 100 connections.
Actually its 151, but you can change this values if needed.
See: http://dev.mysql.com/doc/refman/5.5/en/too-many-connections.html
精彩评论