PostgreSQL버전 : 16
아래와 같이 파티션테이블을 생성한 후, 인덱스를 만들 때 2-1과 2-2의 차이가 무엇이며 어떤 방법을 사용해야 성능이슈가 없을까요?
1. 파티션테이블 생성
create table a.sales (
id int,
sale_date date,
amount decimal
) partition by range (sale_date);
create table a.sales_2023 partition of a.sales for values from ('2023-01-01') to ('2023-12-31');
2. 인덱스 생성
2-1)
create index idx_sales_2023_sale_date on a.sales (sale_date); -- type : partitioned index
2-2)
create index idx_sales_2023_amount on a.sales_2023 (sale_date); -- type : index
|