# Postgres와 MySQL의 인덱스 머지 vs 컴포지트 인덱스 비교

> Clean Markdown view of GeekNews topic #7942. Use the original source for factual precision when an external source URL is present.

## Metadata

- GeekNews HTML: [https://news.hada.io/topic?id=7942](https://news.hada.io/topic?id=7942)
- GeekNews Markdown: [https://news.hada.io/topic/7942.md](https://news.hada.io/topic/7942.md)
- Type: news
- Author: [xguru](https://news.hada.io/@xguru)
- Published: 2022-12-02T10:38:01+09:00
- Updated: 2022-12-02T10:38:01+09:00
- Original source: [sirupsen.com](https://sirupsen.com/index-merges)
- Points: 16
- Comments: 0

## Topic Body

- "컴포지트 인덱스가 인덱스 머지보다 10배 빠름   
Postgres에서는 MySQL보다 그 차이가 더 큰데,   
Postgres가 인덱스 머지가 들어가는 쿼리에 대해서 인덱스-온리 스캔을 지원하지 않기 때문"   
- `SELECT count(*) FROM table WHERE int1000 = 1 AND int100 = 1` 쿼리에 대해서   
(int1000, int100) 컴포지트 인덱스를 만들거나, int1000/int100 에 대해서 개별 인덱스를 만들어서 머지 가능   
- 1천만 레코드를 랜덤 생성한 후 테스트   
  - 컴포지트 인덱스 : 5ms   
  - 인덱스 머지 : MySQL은 30~40ms, Postgres는 30~90ms   
- Postgres를 사용중이라면, 인덱스 머지 기능 사용에 유의할 것

## Comments



_No public comments on this page._
