사용자 도구

사이트 도구


database:mysql:5.6

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
database:mysql:5.6 [2022/02/11 11:32]
kwon37xi [fractional seconds 반올림 문제 해결책]
database:mysql:5.6 [2022/03/15 10:59] (현재)
kwon37xi
줄 23: 줄 23:
 </code> </code>
  
-===== fractional seconds 지원 ===== 
-  * fractional seconds 라는 것은 초(second)보다 작은 단위인 milliseconds, nanoseconds를 뜻하는 것으로 보임. 
-  * [[http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html|MySQL :: MySQL 5.6 Reference Manual :: 11.3.6 Fractional Seconds in Time Values]] 
-  * 5.6 부터 이를 지원하지만, 컬럼을 ''DATETIME(6)''으로 생성해야 한다. 
-  * ''DATETIME(0)'' - fractional second 지원 안함. 
-  * ''DATETIME(6)'' - fractional second 6자리까지 지원 
-  * 그냥 ''DATETIME''(기본으로 ''0''이 지정됨)일 경우 **fractional second 부분이 반올림** 되는 현상이 일어난다. 
-    * 정확히 말하면 컬럼의 밀리세컨드 자리수가 입력데이터보다 적을 때 반올림이 일어나며, 
-    * 이 현상은 SQL 표준에 의거한 것이며 버그가 아니라고 한다. 
- 
-===== fractional seconds 반올림 문제 해결책 ===== 
-  * ''DATETIME''에서 반올림 현상을 없애려면 Hibernate Interceptor나 JPA Entity Listener 등의 차원에서 millisecond 이하를 잘라버려야 한다. 
-  * [[https://gist.github.com/kwon37xi/9205428|MySQL 5.6의 DATETIME ms 반올림 버그와 구버전 JDBC 드라이버의 ms 절삭 버그 조합]] 
-  * [[https://dev.mysql.com/doc/relnotes/connector-j/5.1/en/news-5-1-37.html|MySql Connector/J 5.1.37]] 에 **'' sendFractionalSeconds=true|false''** 프라퍼티가 추가 되었다. 이를 통해 JDBC Driver 차원에서 fractional seconds를 전송하지 않게 ''false'' 옵션을 지정하면 ''datetime(0)''에서도 반올림 현상을 막을 수 있다. 
-> A new connection property, sendFractionalSeconds=true|false, has been introduced. It controls whether fractional seconds in timestamps are to be truncated on the client side or to be sent to the server side for truncation there. See the entry for the new property in [[https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html|Configuration Properties for Connector/J]] for details. Thanks to Kwon Nam Son for contributing the code. (Bug #21304726, Bug #77449) 
- 
-  * 혹시나 ''true|false''간의 성능차이가 매우 큰지 여부를 테스트해 보았는데, 차이 거의 없었다. [[https://github.com/kwon37xi/mysql-jdbc-send-fractional-seconds|mysql-jdbc-send-fractional-seconds performance test]] 
-  * [[database:mariadb|MariaDB]] Connector/J의 경우 ''useFractionalSeconds=false''로 지정하면 millisecond를 전송하지 않는다. 
database/mysql/5.6.1644546766.txt.gz · 마지막으로 수정됨: 2022/02/11 11:32 저자 kwon37xi