Discussion of article "How to Access the MySQL Database from MQL5 (MQL4)" - page 29

 
Viktor Vasilyuk #:

thanks for the clarification. I can't know everything, that's why I'm asking.

I found the solution for myself here.

P.S: Checked for SELECT - it works

Well, the conversion of the query result is allowed, but do not forget that you have a definition of utf8mb4 at the table level, that is, for all fields varchar by default will be used, and if you have a condition in the query for a text field, MySQL will try to implicitly convert. And if you take into account that you may have an index built on a text column, then the optimiser may not pick it up during such a conversion... hence problems with query performance.
So it is desirable to control such things both at the table level and at the level of column definition.
 
Eugeniy Lugovoy #:
Well query result conversion is allowed, but do not forget that you have utf8mb4 definition at the table level, i.e. for all fields varchar will be used by default, and if you have a condition on a text field in your query, MySQL will try to implicitly convert it. And if you take into account that you may have an index built on a text column, then the optimiser may not pick it up during such a conversion... hence problems with query performance.
So it is desirable to control such things both at the table level and at the level of column definition.

there is a description field. Something like "comments", the field is not necessary, just a text explanation. There will be no index.

MySQL utf8mb4 does by default. Can you tell me how to specify in DDL next time? What to change and to what encoding

 
Out of curiosity is MQLmySQL picky about database types?  We're running into an issue where our script used to connect to the database until we migrated to a new database.  Suddenly we have issues with read/write/delete.  All permissions for port 3306 are enabled, and the new db is simply a copy of the old one.

Any ideas?
 
Boaz Nyagaka Moses #:
I keep getting this error:
2022.03.02 20:22:25.198 MySQL-001 EURUSD,M15: Connection error #2059 Authentication plugin 'caching_sha2_password' cannot be loaded: The specified module could not be found.

Did you ever manage to resolve this Boaz?

 

Is there any way to know the number of Fields that can be retrieved after MySqlCursorFetchRow?

Maybe some hidden function like RowFieldsSize ...


As I understand, if there is no Field, MySqlGetFieldAsString returns empty. But also if String Field specifically contains an empty field, it also returns empty. That is, it is not always possible to trace the number of Fields by brute force.


As a crutch you can find out through sql command first, but then select again, but this is already an unnecessary Select.



Please develop the library, very useful thing. Of course long time ago a couple of mysql to build into mt

 

Insert and Update query - only 16 kb query limit ?


If the query is more than 16.000 characters, metatrader crashes (closes). if less, it is fine.

I attach an example of UPDATE for 32.000 characters.


Field for updating in the database - LONGTEXT

Files:
test2.txt  64 kb
 
andreysneg #:

Insert and Update query - only 16kb query limit ?


If the query is more than 16.000 characters, metatrader crashes (closes). if less, it is fine.

I attach an example of UPDATE for 32.000 characters.


Field for updating in the database - LONGTEXT

This is more like a line size limit in MQL :-(

and you can write more compactly :

REPLACE d1 ("t", "o", "h", "l", "c") VALUES (time1,open1,high1,low1,close1), (time2,open2,high2,low2,close2) ....

and/or split into two queries by combining them into a single transaction

 
Hi! Question for experts - how much data and how often I can read from MySQL to MT5 ?
For example, I have data 50 000 elements and I update them in the table every 0,1 sec (numbers). Will MT5 be able to pick them up from MySQL and update them every 0.1 sec? Is there any limitation of the functionality given in this article on KB per 1 query?
 
Alex Renko #:
Hi! Question for experts - how much data and how often I can read from MySQL to MT5 ?
For example, I have data 50 000 elements and I update them in the table every 0,1 sec (numbers). Will MT5 be able to pick them up from MySQL and update them every 0.1 sec? Is there any limitation of the functionality given in this article on KB for 1 query?

Well, the question is certainly interesting ...

I must say that there are no limits on the number of SELECT query rows returned.

The size limit for the query itself is 64 Kb. So if you are trying to update 50k rows of data, it is better to split them into batches, say 1000 rows each, and thus send 50 queries.

As for the speed of 100 ms, if you have the database on one server, and your terminal in which you execute MQL with a connection to the database is somewhat remote, then most likely you will run into network latency, the size of the ping....

For example, if you have a ping of 60 ms between the database server and the terminal, the actual response from the server will be delayed = 60ms (query) + query processing time on the database side + 60ms (response).


This project is just a simple wrapper to access the functionality of dynamic mysql libraries.

The set of functionality is limited to the main practically useful functions, you can expand, add what you need, say add support for asynchronous queries, and then you can send all 50 queries on 1000 lines without waiting for the execution of each in turn.


P.S.: on Github you can see the library sources and preset limits(https://github.com/elugovoy/MQLMySQL-Project/tree/master/MQLMySQL).

P.P.S.: you can also download, modify at your discretion, compile and test.

MQLMySQL-Project/MQLMySQL at master · elugovoy/MQLMySQL-Project
  • elugovoy
  • github.com
MQL & DLL libraries for working with MySQL database - elugovoy/MQLMySQL-Project
 
andreysneg #:

Is there any way to know the number of Fields that can be retrieved after MySqlCursorFetchRow ?

Maybe there is some hidden function like RowFieldsSize ...


As I understand, if there is no Field, MySqlGetFieldAsString returns empty. But also if String Field specifically contains an empty field, it also returns empty. I.e. it is not always possible to track the number of Fields by brute force.


As a crutch you can find out through sql command first, but then select again, but this is already an unnecessary Select.



Please develop the library, very useful thing. Of course, a couple of mysql should be built into mt a long time ago

Hm... and what kind of queries are so tricky at you that it is necessary to determine the number of fields returned by it?

Usually in the SELECT comand only list what is needed in a particular situation. Don't use SELECT *, select only what you need :) this is normal practice.

You should not make crutches, you can take the source code from Github and add a wrapper for mysql_fetch_fields() MySQL API function