You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/08/01 04:40:25 UTC

[GitHub] [skywalking] tristaZero commented on pull request #5215: sql optimize : query alarm in mysql

tristaZero commented on pull request #5215:
URL: https://github.com/apache/skywalking/pull/5215#issuecomment-667468282


   @dagmom @wu-sheng My impression is that MySQL will take some optimization for this SQL, so `1 = 1` does not matter.
   Here is a simple test,
   ``` sql
   mysql> explain select * from business where id = 1;
   +----+-------------+----------+------------+-------+---------------+---------+---------+-------+------+----------+-------+
   | id | select_type | table    | partitions | type  | possible_keys | key     | key_len | ref   | rows | filtered | Extra |
   +----+-------------+----------+------------+-------+---------------+---------+---------+-------+------+----------+-------+
   |  1 | SIMPLE      | business | NULL       | const | PRIMARY       | PRIMARY | 4       | const |    1 |   100.00 | NULL  |
   +----+-------------+----------+------------+-------+---------------+---------+---------+-------+------+----------+-------+
   1 row in set, 1 warning (0.02 sec)
   
   mysql> explain select * from business where 1=1 and id = 1;
   +----+-------------+----------+------------+-------+---------------+---------+---------+-------+------+----------+-------+
   | id | select_type | table    | partitions | type  | possible_keys | key     | key_len | ref   | rows | filtered | Extra |
   +----+-------------+----------+------------+-------+---------------+---------+---------+-------+------+----------+-------+
   |  1 | SIMPLE      | business | NULL       | const | PRIMARY       | PRIMARY | 4       | const |    1 |   100.00 | NULL  |
   +----+-------------+----------+------------+-------+---------------+---------+---------+-------+------+----------+-------+
   ```
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org