JSONB 데이터
{
"services": {
"tire": {
"maxInch": 23,
"minInch": 13,
"isActivated": true,
"rFTHandleable": true,
"incomeVehicleHandleable": true,
"domesticVehicleHandleable": true,
"incomeElectricVehicleHandleable": true,
"domesticElectricVehicleHandleable": true
},
"battery": {},
"engineoil": {},
"airconFilter": {},
"wheelalignment": {
"isActivated": true,
"incomeVehicleHandleable": true,
"domesticVehicleHandleable": true,
"incomeElectricVehicleHandleable": true,
"domesticElectricVehicleHandleable": true
}
},
"orderCutOff": {
"day": 1,
"hour": 14,
"minute": 0
}
}
JSON
복사
위와 같이 JSONB 데이터를 저장하는 postgresql 컬럼이 있다고 가정해보자.
일반적으로 JSONB 데이터타입에서 특정 키나 경로에 대해 효율적으로 설계된 타입은 GIN(Generalized Inverted Index)이다.
해당 컬럼을 조회하는 로직은 평균적으로 1초 내 외이며 isActivated = true와 같은 방식으로 쿼리가 작성된다.
GIN 인덱스 생성
CREATE INDEX "IDX_repairShopOption_services" ON "RepairShopOption" USING GIN (options jsonb_path_ops);
// jsonb_path_ops 연산자 클래스는 JSONB 데이터 타입에 대한 효율적인 경로 검색을 지원합니다.
SQL
복사