I am facing slow performance while connecting to a remote mariadb database from .exe built using pyinstaller on windows 10 as compared to directly from pycharm IDE.
So, below is the sample code:
import MySQLdb
try:
conn = MySQLdb.connect(host=database_host, port=database_port, user=database_user,
passwd=database_password, db=database_name)
except MySQLdb.OperationalError as e:
# error message
print('Error: ', e)
If I run this code from pycharm, the connection time is ~100 milliseconds to a remote mariadb database.
If I run the same code using a windows executable (.exe built using pyinstaller) the execution time is approximately 2 seconds to the same remote mariadb database.
pyinstaller command:
pyinstaller -y --add-data "C:\path\to\data" --icon="C:\path\to\icon.ico" --hidden-import babel.numbers package.path.MainModule.py
I installed maridb on the local windows machine and didn't find any performance difference. So, the performance difference is observed only for the remote connection.
This is is a significant difference in the performance. Now, I can't figure out what could be causing this. Any direction will be greatly appreciated.