ClickHouse HOLs
GitHub

MySQL vs ClickHouse Point Query 성능 비교

Related notes · 관련 글: MySQL 마이그레이션시 Point Query 성능 극대화

게임 서버에서 플레이어 마지막 접속 정보 조회 성능 비교 테스트

테스트 목적

환경


실행 방법

1. 컨테이너 시작

cd usecase/mysql-protocol-benchmark
docker-compose up -d

2. ClickHouse 데이터 초기화 (1-2분)

docker exec -i clickhouse-test clickhouse-client < init/clickhouse/init.sql

3. MySQL 데이터 초기화 (10-15분)

docker exec -it mysql-test mysql -u testuser -ptestpass gamedb < init/mysql/02_generate_data.sql

또는 MySQL 접속 후 직접 실행:

docker exec -it mysql-test mysql -u testuser -ptestpass gamedb
mysql> source /docker-entrypoint-initdb.d/02_generate_data.sql

4. 연결 테스트

# MySQL
mysql -h localhost -P 3306 -u testuser -ptestpass gamedb -e "SELECT COUNT(*) FROM player_last_login;"

# ClickHouse (MySQL Protocol)
mysql -h localhost -P 9004 -u testuser -ptestpass gamedb -e "SELECT count() FROM player_last_login;"

5. 벤치마크 실행

pip install mysql-connector-python
python benchmark.py

ClickHouse 최적화 포인트

1. Primary Key ORDER BY

ORDER BY player_id

2. Bloom Filter Index

INDEX idx_player_id_bloom player_id TYPE bloom_filter(0.01) GRANULARITY 1

디렉토리 구조

mysql-protocol-benchmark/
├── docker-compose.yml
├── lab.yaml                              # 실습 메타데이터 (게시 키)
├── benchmark.py                          # 포인트 쿼리 벤치마크
├── benchmark_comprehensive.py            # 종합 벤치마크
├── benchmark_report.txt, benchmark_results.json
├── benchmark_comprehensive_report.txt, benchmark_comprehensive_results.json
├── FINAL_REPORT.md, PERFORMANCE_REPORT.md
├── CLICKHOUSE_TUNING_GUIDE.md
├── README.md
└── init/
    ├── clickhouse/
    │   ├── config.xml
    │   ├── users.xml
    │   └── init.sql
    └── mysql/
        ├── 01_schema.sql
        └── 02_generate_data.sql

정리

docker-compose down -v

License

MIT — same as the rest of the repository.

MySQL vs ClickHouse Point Query 성능 비교

Related notes · 관련 글: MySQL 마이그레이션시 Point Query 성능 극대화

게임 서버에서 플레이어 마지막 접속 정보 조회 성능 비교 테스트

테스트 목적

환경


실행 방법

1. 컨테이너 시작

cd usecase/mysql-protocol-benchmark
docker-compose up -d

2. ClickHouse 데이터 초기화 (1-2분)

docker exec -i clickhouse-test clickhouse-client < init/clickhouse/init.sql

3. MySQL 데이터 초기화 (10-15분)

docker exec -it mysql-test mysql -u testuser -ptestpass gamedb < init/mysql/02_generate_data.sql

또는 MySQL 접속 후 직접 실행:

docker exec -it mysql-test mysql -u testuser -ptestpass gamedb
mysql> source /docker-entrypoint-initdb.d/02_generate_data.sql

4. 연결 테스트

# MySQL
mysql -h localhost -P 3306 -u testuser -ptestpass gamedb -e "SELECT COUNT(*) FROM player_last_login;"

# ClickHouse (MySQL Protocol)
mysql -h localhost -P 9004 -u testuser -ptestpass gamedb -e "SELECT count() FROM player_last_login;"

5. 벤치마크 실행

pip install mysql-connector-python
python benchmark.py

ClickHouse 최적화 포인트

1. Primary Key ORDER BY

ORDER BY player_id

2. Bloom Filter Index

INDEX idx_player_id_bloom player_id TYPE bloom_filter(0.01) GRANULARITY 1

디렉토리 구조

mysql-protocol-benchmark/
├── docker-compose.yml
├── lab.yaml                              # 실습 메타데이터 (게시 키)
├── benchmark.py                          # 포인트 쿼리 벤치마크
├── benchmark_comprehensive.py            # 종합 벤치마크
├── benchmark_report.txt, benchmark_results.json
├── benchmark_comprehensive_report.txt, benchmark_comprehensive_results.json
├── FINAL_REPORT.md, PERFORMANCE_REPORT.md
├── CLICKHOUSE_TUNING_GUIDE.md
├── README.md
└── init/
    ├── clickhouse/
    │   ├── config.xml
    │   ├── users.xml
    │   └── init.sql
    └── mysql/
        ├── 01_schema.sql
        └── 02_generate_data.sql

정리

docker-compose down -v

License

MIT — same as the rest of the repository.

Open this lab on GitHub →GitHub에서 이 실습 열기 →