티스토리 뷰
반응형
date 타입으로 저장된 컬럼을 Select 해올때 between과 대소 비교 연산자 성능의 차이에 대해 테스트 해보려고 한다.
일단 더미데이터 테이블의 DDL은 다음과 같다.
create table test_datetime
(
id bigint unsigned auto_increment
primary key,
isTest tinyint default 0 not null,
createdAt datetime(6) default CURRENT_TIMESTAMP(6) not null,
updatedAt datetime(6) default CURRENT_TIMESTAMP(6) not null on update CURRENT_TIMESTAMP(6),
deletedAt datetime(6) null
);
create index IDX_isTest
on test_datetime (isTest);
데이터는 프로시저를 사용하여 손쉽게 만들었다.
https://seung-min.tistory.com/50
1억개의 더미데이터중 Beteween과 대소 비교연산자를 사용하여 각각 1500건, 5000건, 400만건, 1000만건, 3000만건, 5000만건, 7000만건 Select를 진행하였다.
총 결과를 정리해보면 다음과 같다. 단위는 ms 이다.
1,500 | 5,000 | 4,000,000 | 10,000,000 | 30,000,000 | 50,000,000 | 70,000,000 | |
Beteween | 56.43 | 59.56 | 65.188 | 69.892 | 103.354 | 131.961 | 150.78 |
대소 비교 연산자(>,<) | 34.587 | 36.746 | 39.308 | 47.83 | 74.196 | 107.765 | 136.849 |
인덱스가 걸리지 않은 Date 타입을 조회할 경우 Beteween 연산자 보다 대소비교 연산자가 훨씬 빠름을 알 수있다.
반응형
'SQL' 카테고리의 다른 글
[SQL] mySQL Procedure 사용하여 반복문 사용하기 (0) | 2023.02.05 |
---|---|
[SQL] mySQL 계정 생성, 삭제, 권한 부여 (0) | 2022.05.03 |
[SQL] mySQL Query 사용 데이터 암호화 (0) | 2021.11.12 |
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- linux/amd64/v2
- react #react-spinners #modal loading #overlay #로딩창 #react 로딩창 만들기
- ERROR: failed to solve: no support for running processes with linux/amd64/v3 platform
- AWS #인바운드 #SSH #인스턴스 연결
- node.js #node.js pdf만들기 #node.js pdfkit
- Pytorch #Yolov5 #Segementation
- 이미지 전송 # 이미지 업로드 #이미지 여러장 #이미지 여러장 업로드 #react 이미지 업로드 #react 이미지 여러장 업로드
- Express multer #Express File 저장 #node.js
- mysql date type
- JavaScript #Programmers #lvl2 #프로그래머스 오픈채팅방 # 오픈채팅방 문제
- supported: linux/amd64
- Procedure #mysql #mysql Procedure #mysql 반복문 #Procedure 반복문 #mysql insert 반복문
- docker # docker build # m1 docker build
- node.js 파일 저장
- mysql date
- mysql date between performance
- BOJ #JS
- docker mysql
- PDF #pdfkit
- excel 파일 만들기 #node.js #express excel 파일 만들기 #데이터 입력해서 excel 파일 만들기
- Swal #sweetalert2 #alert #알림창 띄우기 #react swal
- reack-cookies #아이디 저장하기 #react 아이디 저장 #react cookie #리엑트 아이디 저장하기
- react #img 전송
- see ec2 instance connect prerequisites at https://docs.aws.amazon.com/awsec2/latest/userguide #인스턴스 연결 안됨
- FormData #FormData 파일전송 #FormData append json # React FormData File #React FormData append Json
- React filter #js Includes #React Filter includes
- PoolCluster : Error: connect ECONNREFUSED 127.0.0.1:3306)
- Mac docker.for.mac.host.internal
- ec2 instance connect is unable to connect to your instance. ensure your instance network settings are configured correctly for ec2 instance connect. for more information
- mysql date between # mysql date between 대소 비교 연산자
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함