인덱스 생성
Oracle
CREATE INDEX customer_city_idx ON customer(city) ONLINE;ONLINE은 테이블 락 없이 생성한다. 유일 인덱스는 CREATE UNIQUE INDEX, 복합 인덱스는 (a, b)를 사용한다.
PostgreSQL
CREATE INDEX CONCURRENTLY customer_city_idx ON customer(city);CONCURRENTLY는 테이블 쓰기를 블로킹하지 않지만 트랜잭션 블록 안에서는 실행할 수 없고 더 느리다.
MySQL
CREATE INDEX customer_city_idx ON customer(city);
-- Lock-free: ... ALGORITHM=INPLACE, LOCK=NONE;InnoDB는 대부분의 인덱스를 온라인으로 추가한다. 대형 테이블에서는 LOCK=NONE으로 쓰기를 허용한다.
SQL Server
CREATE NONCLUSTERED INDEX IX_customer_city
ON dbo.customer (city)
WITH (ONLINE = ON);ONLINE은 Enterprise 기능이다. 커버링 컬럼은 INCLUDE (col1, col2)를 사용한다.
MongoDB
db.customer.createIndex({ city: 1 })
// Unique: { city: 1 }, { unique: true }
// Built in the background without blocking (default behavior in 4.2+)1은 오름차순, -1은 내림차순이다. 대형 컬렉션에서는 secondary에서 먼저 생성하면 부하가 줄어든다.
Redis
# Not applicable (core). If RediSearch is present:
# FT.CREATE idx ON HASH PREFIX 1 customer: SCHEMA city TAG보조 인덱스는 RediSearch 모듈에서만 제공된다. 기본 Redis는 키로 접근한다.