0

I have an C# app that accesses LAN based mysql server for database operations, it works fine. However, as soon as I try to access a remote mysql server the time to open MySQL connection and query execution increases considerably this causes a hang like condition on the main thread.

Just opening a MySQL connection takes about 1-3 seconds affecting the GUI.

Is there any way to avoid this except for running MySQL operations on another thread?

Shyamal Parikh
  • 2,988
  • 4
  • 37
  • 78

1 Answers1

2

There could be 2 reason. first mysql server has lots of open connections so it has slowed to manage new client, so check the server status with root super privileges or process privileges like root account-

Mysql> show processlist;
+----+-------------+-------------------+------+---------+------+----------------------------------+------------------+
| Id | User        | Host              | db   | Command | Time | State                            | Info             |
+----+-------------+-------------------+------+---------+------+----------------------------------+------------------+
|  2 | system user |                   | NULL | Connect | 1188 | Waiting for master to send event | NULL             |
|  5 | root        | smart.local:39850 | NULL | Query   |    0 | init                             | show processlist |
+----+-------------+-------------------+------+---------+------+----------------------------------+------------------+
2 rows in set (0.00 sec)

Second possiblity there could be problem with connector. The issue was also present on our side with MySql Connector .Net 6.6.5. The MySql Connector .Net 6.8.3 is solving this issue.

if both are ok then the link can be helpful.

Very slow opening MySQL connection using MySQL Connector for .net

Community
  • 1
  • 1
Hitesh Mundra
  • 1,538
  • 1
  • 9
  • 13
  • Thanks a lot. Actually I think it is the issue with the network. I made a PC in LAN to forward it's port to public IP may be slow connection may be related to router or something. – Shyamal Parikh Jul 02 '15 at 15:57
  • Nope my question still remains what in the network may cause this issue? – Shyamal Parikh Jul 02 '15 at 16:11
  • @shyamalparikh may be your internet connection slow – Hitesh Mundra Jul 02 '15 at 16:20
  • Well as per my app stats it only require 500bytes/s download speed while the database host has a speed of 52kB/s so I may be the speed is not the issue. – Shyamal Parikh Jul 02 '15 at 16:31
  • @shyamalparikh try the connection with localhost, If it slow then problem with your mysql connector other wise it seems slow interenet connection – Hitesh Mundra Jul 02 '15 at 17:12
  • But on the same internet connection sites like Facebook and Youtube are running flawlessly. I have created another question with more details http://stackoverflow.com/questions/31320267/remote-mysql-access-taking-a-long-time – Shyamal Parikh Jul 09 '15 at 14:19