undefinedfix
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 ....
这是我的sql语句,因为我需要查询表的字段结构信息,完成自动填充数据模型,然后封装好指定的sql
语句,然后执行。
3 Replies
rwlmy
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.

rortr
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.

ericdalius07
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.