Sign in

What should I pay attention to when I need to frequently get the field details of the table from the MySQL system table? At present, I find that the index is not used.

teknologitara edited in Thu, 19 May 2022
select fields from information_schema.COLUMNS  where ....
3 Replies
commented on Thu, 19 May 2022

You can cache the table field, use the table name as the key, and then set a certain expiration time, because the table field will change less, so you don't have to look up the table every time, and it will be better.

commented on Thu, 19 May 2022

information_ The table under schema belongs to the memory engine and cannot be indexed. It is normal that SQL cannot use the index. It depends on whether you need accurate data. If not, you can cache the relevant information first. If you have to look up the table every time, it is recommended to execute from the database.

commented on Fri, 20 May 2022

First floor solution -- cache the fields of the table. It can be realized by redis and memcached.

lock This question has been locked and the reply function has been disabled.