Hi All,
Phalcon find function adds extra queries:
SELECT IF(COUNT(*)>0, 1 , 0) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='mytable';
DESCRIBE mytable;
How to avoid this please?
Thanks a lot in advance
|
|
Jun '16 |
7 |
628 |
0 |
In addition to Wojciech answer: docs link in case someone else needs it: https://docs.phalcon.io/en/latest/reference/models-metadata.html
The section you need is: Caching Meta-Data
You can link directly to https://docs.phalcon.io/en/latest/reference/models-metadata.html#caching-meta-data after the section name there is link to it.
In addition to Wojciech answer: docs link in case someone else needs it: https://docs.phalcon.io/en/latest/reference/models-metadata.html
The section you need is: Caching Meta-Data
What do you think how ORM is suppose to find basic info about your tables if not in INFORMATION_SCHEMA?
Every ORM out there would do the same.
And you have N + 1 problem too, if you're that much concerned with INFO SCHEMA quries. https://use-the-index-luke.com/sql/join/nested-loops-join-n1-problem
It is also very wise to disable stats update on metadata fetching:
innodb_stats_on_metadata = 0
this will prevent statistic update when we query information_schema.
Most likely we do not want it anyway. This will not make Innodb to operate without statistics at all as Innodb will still compute statistics for the table first time it opens it.*
On MariaDB 10.1, works like a charm with 500 concurrent connections.
I don't use Model::find() function any more as it slows down my server a lot (I have thousands of tables)