2016년 12월 1일 목요일

MariaDB Primary Key Plan

-. PK 를 사용 하여 조회 조건에 = 조회를 하면 select 는 당연히 상수 처리 해서 한건만 access 하는데 delete, update 는 상수 처리를 못해서 range scan 을 합니다. 옵티마이저가 같은 방식으로 처리를 한다면 delete, update 도 상수 처리를 해서 딱 한건만 access 하는 것이 맞을것 같은데요.. 혹시 이런 이유를 아시는 분 있을까요? 참고로 mariadb 10.0 대 버전인데 제가 볼때는 mysql도 같을거라 판단이 듭니다.

update or delete
 
+------+-------------+--------------+-------+---------------+---------+---------+------+------+-------------+
| id   | select_type | table        | type  | possible_keys | key     | key_len | ref  | rows | Extra       |
+------+-------------+--------------+-------+---------------+---------+---------+------+------+-------------+
| 1    | SIMPLE      | ox_campaigns | range | PRIMARY       | PRIMARY | 3       | NULL | 1    | Using where |
+------+-------------+--------------+-------+---------------+---------+---------+------+------+-------------+
 
select
 
+------+-------------+--------------+-------+---------------+---------+---------+-------+------+-------+
| id   | select_type | table        | type  | possible_keys | key     | key_len | ref   | rows | Extra |
+------+-------------+--------------+-------+---------------+---------+---------+-------+------+-------+
| 1    | SIMPLE      | ox_campaigns | const | PRIMARY       | PRIMARY | 3       | const |    1 |       |
+------+-------------+--------------+-------+---------------+---------+---------+-------+------+-------+


참고 문서: http://bugs.mysql.com/bug.php?id=69887

댓글 없음:

댓글 쓰기