在软件Navicat中,如何查看执行一条SQL语句的耗时。
如select * from table_name where id = '1' 如何查看当前的语句耗时。
==============================================================
通过测试发下:
SELECT * FROM idc_logistics_assign_rules WHERE id = '100'; SELECT * FROM idc_logistics_assign_rules WHERE id = '200'; //时间: 0.035s SELECT * FROM idc_logistics_assign_rules WHERE id IN ('100','200') //时间: 0.020s
我的id是主键,肯定会走索引的,那么走索引的查询应该更快啊。使用IN关键字是不走索引的,但是为什么查询要比两次主键id查询块呢?求解释。
Your in here is indexed. After executing
explain SELECT * FROM idc_logistics_assign_rules WHERE id IN ('100','200')
you will see the index usage, which is useful for the index. To get the correct query time, add SQL_NO_CACHE注意
: Do you need to use index in? It depends on the situation. That is, it depends on whether the index can be used. When the range of in is the clustered index in(1,2), it will be automatically optimized by MSSQL to id=1 or id=2. You can use explain to see it. The row it returns is 2 in(1,2) and id=1. or id=2 explain returns the same data. I can tell you responsibly that it is a useful index. Most of the mentions on the Internet about not using indexes are old materials, which have been optimized since MSSQL2K.My navicat is in the bottom row
It’s almost like
到处都是
Your id must be of type int. Why do we need to add single quotes when querying
There is query time in the lower right corner in seconds