I just read that EZ query methods manage connection string automatically. I need to run multiple queries per api call, so with current solution I feel that I need to replace all my mysql methods calls with dbQuery to use same connection and avoid performance issues in future.
So few ideas came to my mind:
-
We already need to pass database name to method, like core.mysql.select(db_name, select_tbl). So can it be variational parameter: db_name or db_connection (string or table).
-
Coronium can work in this way (don’t know how difficult it is to implement with current architecture):
a) request started, have an ez_db_connections lua table initialized
b ) core.mysql.select(db_name, select_tbl) called, inside it cheks if ez_db_connections already contains db_name then just use opened connection, otherwise create connection and put it into ez_db_connections
c) after api method ended close all connections in ez_db_connections
- Advanced question: if I will use one db connection for multiple queries how many transactions do I have? I guess it would be transaction per query and I guess any serious project will require transactions in some places.