본문 바로가기

개발

mysql 5.6 에서 5.7 업그레이드 후 쿼리 속도 이슈

안녕하세요 .

정말 귀차니즘의 끝을 달리다가 글을 씁니당...

 

일단 이슈는 제목 그대로 mysql 버전 업그레이드 되면서 일부 select query 가 급격히 느려진 현상입니다.

 

아래는 제가 문제 접근부터 해결 까지 기록한 내용입니다.

 

 

 

 

 

 

********************************************************************************************************

위 부분에서 버전이 업그레이드 됨으로써 의도한데로 쿼리가 작동하지 않고 , 그로 인해 더 많은 데이터를 검색해야하는 비용이 발생하여 쿼리 속도가 느려지게 되는 문제가 발생하였습니다. 이를 해결하기 위해 병합되지않는 룰 중 하나인 group by 를 사용하여 아래 왼쪽 처럼 기존에 의도한대로 쿼리가 동작할 수 있도록 진행 하여 문제를 해결 하였습니다. 추가로 공부를 하면서 인덱스 사용법을 알게되어 아래와 같인 인덱스 룰 또한 추가하여 속도를 더 개선하였습니다.

********************************************************************************************************

 

 

https://dev.mysql.com/blog-archive/derived-tables-in-mysql-5-7

 

MySQL :: Derived Tables in MySQL 5.7

In MySQL 5.7, we have enhanced the optimizer so that derived tables and views are handled more consistently. Just to recap: A derived table is a subquery that can take the place of a table in the FROM clause of an SQL statement. A derived table that is emb

dev.mysql.com

https://dev.mysql.com/blog-archive/mysql-5-7-improved-performance-of-queries-with-derived-tables/

 

MySQL :: MySQL 5.7: Improved Performance of Queries with Derived Tables

In a recent blog post my colleague Roy presented his work for MySQL 5.7 that makes the query optimizer merge sub-queries in the  FROM clause (so-called derived tables) with the outer query.  I will in this blog post show an example of how this work impro

dev.mysql.com