Share
Sign In
🥊

PostgreSQL Index 종류

Guidelines
The default Postgres index is a B-tree index.
You should always properly analyze your workload using query execution plans to determine the suitable Postgres index type.
Always create indexes on the most executed and costly queries. Avoid creating an index to satisfy a specific query.
As per best practice, always define a primary or unique key in a Postgres table. It automatically creates the B-tree index.
Avoid creating multiple indexes on a single column. It is better to look at which index is appropriate for your workload and drop the unnecessary indexes.
There is no specific limit on the number of indexes in the table; however, try to create the minimum indexes satisfying your workload.
목차
B-tree
B-tree is the default index in Postgres.
특정 값 검색, 스캔 범위, 데이터 정렬, 패턴 일치에 적합하다. Postgres에서 인덱스 유형을 지정하지 않으면 Lehman & Yao Algorithm and B+Trees 알고리즘을 따른다.
쿼리 플래너가 인덱싱된 열이 다음 연산자 중 하나를 사용하는 비교에 포함될 때 마다 B-tree 인덱스 사용을 고려한다.
between, in, is null, is not null 등의 조건과 함께 B트리 인덱스와 함께 사용할 수 있다.
B-트리 인덱스는 정렬된 순서로 데이터를 검색하는 데에도 사용할 수 있다. 이것은 단순한 스캔 및 정렬보다 항상 빠르지는 않지만 종종 도움이 된다.
인덱스에 사용 가능 연산자 : < <= = >= >
Hash
Hash indexes store a 32-bit hash code derived from the value of the indexed column.
해시 인덱스는 단순 일치(동등성) 비교를 처리하기 적합하다. 해시 인덱스가 된 열을 사용 할 경우 쿼리 플래너는 인덱싱된 열이 등호 연산자를 사용하는 exact match에 포함될 때 마다 해시 인덱스 사용을 고려한다.
인덱스에 사용 가능 연산자 : =
예제
GiST
GiST indexes are not a single kind of index, but rather an infrastructure within which many different indexing strategies can be implemented.
GiST(Generalized Search Tree) 인덱스는 인덱스이 종류라기 보단 인덱싱 전략에 도움이 되는 인프라 구조라 할 수 있다.
GiST 인덱스를 사용할 수 있는 특정 연산자는 인덱싱 전략(연산자 클래스)에 따라 다르다. 가령, PostgreSQL의 표준 배포에는 다음 연산자를 사용하여 여러 2차원 기하학적 데이터 유형을 인덱싱 할 수 있다.
또한 B-트리 또는 R-트리와 같은 다양한 전략을 구현할 수도 있다.
포함되어야 하는 연산자 :
예제
SP-GiST
SP-GiST indexes, like GiST indexes, offer an infrastructure that supports various kinds of searches.
SP-GiST는 다양한 비균형 디스크(non-balanced) 기반 데이터 구조(quadtree, k-d tree, radix tree) 구현을 허용한다.
공간 분리 GiST 인덱스를 통해 분할된 검색 트리를 활용하여 균형이 맞지 않은(non-balanced) 데이터 구조를 인덱싱 하는 데 유용하다.
포함되어야 하는 연산자 :
예제
GIN
GIN 인덱스는 배열, jsonb, range type과 같이 여러 복잡한 원소를 포함하는 데이터나 전체 텍스트 검색과 같은 데이터에 적합한 “역 인덱스”이다.
반전된 인덱스에는 각 구성 요서 값에 대한 별도의 항목이 포함되어 있으며, 특정 구성 요소 값이 있는지 테스트 하는 쿼리를 효과적으로 처리할 수 있다.
예를 들어 사용자가 검색 문자열 "raj"를 입력하면 Rajendra, Raju 및 Hansraj와 같은 이름에 대한 모든 행을 반환해야하는 경우 GIN 인덱스를 사용하기 좋다.
ST 및 SP-GiST와 마찬가지로 GIN은 다양한 사용자 정의 인덱싱 전략을 지원할 수 있으며 GIN 인덱스를 사용할 수 있는 특정 연산자는 인덱싱 전략에 따라 다르다.
아래의 연산자를 사용하여 인덱싱된 쿼리를 지원하는 배열용 GIN 연산자 클래스가 포함되어 있다.
예시
BRIN
BRIN indexes (a shorthand for Block Range INdexes) store summaries about the values stored in consecutive physical block ranges of a table.
Block Range INdexes의 줄임말인 BRIN 인덱스는 테이블의 물리 블록의 대한 값을 요약(최대값 , 최소값, 페이지 번호) 저장해두는 인덱스를 말한다.
만약 페이지 번호가 수정되지 않는다면 BRIN 값은 동일하게 유지된다.
테이블 행의 물리적 순서와 상관 관계가 좋은 값에 효과적이다.
GiST, SP-GiST 및 GIN과 마찬가지로 BRIN은 다양한 인덱싱 전략을 지원할 수 있으며 BRIN 인덱스를 사용할 수 있는 특정 연산자는 인덱싱 전략에 따라 다르다.
선형 정렬 순서가 있는 데이터(타임스탬프, 온도) 유형의 경우, 인덱싱된 데이터는 열의 최소값 및 최대값 사이의 블록 범위에 해당한다. 또한 이 경우 b-tree 인덱스에 비해 스토리지를 덜 사용한다.
예제
List indexes
Guidelines
The default Postgres index is a B-tree index.
You should always properly analyze your workload using query execution plans to determine the suitable Postgres index type.
Always create indexes on the most executed and costly queries. Avoid creating an index to satisfy a specific query.
As per best practice, always define a primary or unique key in a Postgres table. It automatically creates the B-tree index.
Avoid creating multiple indexes on a single column. It is better to look at which index is appropriate for your workload and drop the unnecessary indexes.
There is no specific limit on the number of indexes in the table; however, try to create the minimum indexes satisfying your workload.
목차
B-tree
B-tree is the default index in Postgres.
특정 값 검색, 스캔 범위, 데이터 정렬, 패턴 일치에 적합하다. Postgres에서 인덱스 유형을 지정하지 않으면 Lehman & Yao Algorithm and B+Trees 알고리즘을 따른다.
쿼리 플래너가 인덱싱된 열이 다음 연산자 중 하나를 사용하는 비교에 포함될 때 마다 B-tree 인덱스 사용을 고려한다.
between, in, is null, is not null 등의 조건과 함께 B트리 인덱스와 함께 사용할 수 있다.
B-트리 인덱스는 정렬된 순서로 데이터를 검색하는 데에도 사용할 수 있다. 이것은 단순한 스캔 및 정렬보다 항상 빠르지는 않지만 종종 도움이 된다.
인덱스에 사용 가능 연산자 : < <= = >= >
Hash
Hash indexes store a 32-bit hash code derived from the value of the indexed column.
해시 인덱스는 단순 일치(동등성) 비교를 처리하기 적합하다. 해시 인덱스가 된 열을 사용 할 경우 쿼리 플래너는 인덱싱된 열이 등호 연산자를 사용하는 exact match에 포함될 때 마다 해시 인덱스 사용을 고려한다.
인덱스에 사용 가능 연산자 : =
예제
GiST
GiST indexes are not a single kind of index, but rather an infrastructure within which many different indexing strategies can be implemented.
GiST(Generalized Search Tree) 인덱스는 인덱스이 종류라기 보단 인덱싱 전략에 도움이 되는 인프라 구조라 할 수 있다.
GiST 인덱스를 사용할 수 있는 특정 연산자는 인덱싱 전략(연산자 클래스)에 따라 다르다. 가령, PostgreSQL의 표준 배포에는 다음 연산자를 사용하여 여러 2차원 기하학적 데이터 유형을 인덱싱 할 수 있다.
또한 B-트리 또는 R-트리와 같은 다양한 전략을 구현할 수도 있다.
포함되어야 하는 연산자 :
예제
SP-GiST
SP-GiST indexes, like GiST indexes, offer an infrastructure that supports various kinds of searches.
SP-GiST는 다양한 비균형 디스크(non-balanced) 기반 데이터 구조(quadtree, k-d tree, radix tree) 구현을 허용한다.
공간 분리 GiST 인덱스를 통해 분할된 검색 트리를 활용하여 균형이 맞지 않은(non-balanced) 데이터 구조를 인덱싱 하는 데 유용하다.
포함되어야 하는 연산자 :
예제
GIN
GIN 인덱스는 배열, jsonb, range type과 같이 여러 복잡한 원소를 포함하는 데이터나 전체 텍스트 검색과 같은 데이터에 적합한 “역 인덱스”이다.
반전된 인덱스에는 각 구성 요서 값에 대한 별도의 항목이 포함되어 있으며, 특정 구성 요소 값이 있는지 테스트 하는 쿼리를 효과적으로 처리할 수 있다.
예를 들어 사용자가 검색 문자열 "raj"를 입력하면 Rajendra, Raju 및 Hansraj와 같은 이름에 대한 모든 행을 반환해야하는 경우 GIN 인덱스를 사용하기 좋다.
ST 및 SP-GiST와 마찬가지로 GIN은 다양한 사용자 정의 인덱싱 전략을 지원할 수 있으며 GIN 인덱스를 사용할 수 있는 특정 연산자는 인덱싱 전략에 따라 다르다.
아래의 연산자를 사용하여 인덱싱된 쿼리를 지원하는 배열용 GIN 연산자 클래스가 포함되어 있다.
예시
BRIN
BRIN indexes (a shorthand for Block Range INdexes) store summaries about the values stored in consecutive physical block ranges of a table.
Block Range INdexes의 줄임말인 BRIN 인덱스는 테이블의 물리 블록의 대한 값을 요약(최대값 , 최소값, 페이지 번호) 저장해두는 인덱스를 말한다.
만약 페이지 번호가 수정되지 않는다면 BRIN 값은 동일하게 유지된다.
테이블 행의 물리적 순서와 상관 관계가 좋은 값에 효과적이다.
GiST, SP-GiST 및 GIN과 마찬가지로 BRIN은 다양한 인덱싱 전략을 지원할 수 있으며 BRIN 인덱스를 사용할 수 있는 특정 연산자는 인덱싱 전략에 따라 다르다.
선형 정렬 순서가 있는 데이터(타임스탬프, 온도) 유형의 경우, 인덱싱된 데이터는 열의 최소값 및 최대값 사이의 블록 범위에 해당한다. 또한 이 경우 b-tree 인덱스에 비해 스토리지를 덜 사용한다.
예제
List indexes
Guidelines
The default Postgres index is a B-tree index.
You should always properly analyze your workload using query execution plans to determine the suitable Postgres index type.
Always create indexes on the most executed and costly queries. Avoid creating an index to satisfy a specific query.
As per best practice, always define a primary or unique key in a Postgres table. It automatically creates the B-tree index.
Avoid creating multiple indexes on a single column. It is better to look at which index is appropriate for your workload and drop the unnecessary indexes.
There is no specific limit on the number of indexes in the table; however, try to create the minimum indexes satisfying your workload.
목차
B-tree
B-tree is the default index in Postgres.
특정 값 검색, 스캔 범위, 데이터 정렬, 패턴 일치에 적합하다. Postgres에서 인덱스 유형을 지정하지 않으면 Lehman & Yao Algorithm and B+Trees 알고리즘을 따른다.
쿼리 플래너가 인덱싱된 열이 다음 연산자 중 하나를 사용하는 비교에 포함될 때 마다 B-tree 인덱스 사용을 고려한다.
between, in, is null, is not null 등의 조건과 함께 B트리 인덱스와 함께 사용할 수 있다.
B-트리 인덱스는 정렬된 순서로 데이터를 검색하는 데에도 사용할 수 있다. 이것은 단순한 스캔 및 정렬보다 항상 빠르지는 않지만 종종 도움이 된다.
인덱스에 사용 가능 연산자 : < <= = >= >
Hash
Hash indexes store a 32-bit hash code derived from the value of the indexed column.
해시 인덱스는 단순 일치(동등성) 비교를 처리하기 적합하다. 해시 인덱스가 된 열을 사용 할 경우 쿼리 플래너는 인덱싱된 열이 등호 연산자를 사용하는 exact match에 포함될 때 마다 해시 인덱스 사용을 고려한다.
인덱스에 사용 가능 연산자 : =
예제
GiST
GiST indexes are not a single kind of index, but rather an infrastructure within which many different indexing strategies can be implemented.
GiST(Generalized Search Tree) 인덱스는 인덱스이 종류라기 보단 인덱싱 전략에 도움이 되는 인프라 구조라 할 수 있다.
GiST 인덱스를 사용할 수 있는 특정 연산자는 인덱싱 전략(연산자 클래스)에 따라 다르다. 가령, PostgreSQL의 표준 배포에는 다음 연산자를 사용하여 여러 2차원 기하학적 데이터 유형을 인덱싱 할 수 있다.
또한 B-트리 또는 R-트리와 같은 다양한 전략을 구현할 수도 있다.
포함되어야 하는 연산자 :
예제
SP-GiST
SP-GiST indexes, like GiST indexes, offer an infrastructure that supports various kinds of searches.
SP-GiST는 다양한 비균형 디스크(non-balanced) 기반 데이터 구조(quadtree, k-d tree, radix tree) 구현을 허용한다.
공간 분리 GiST 인덱스를 통해 분할된 검색 트리를 활용하여 균형이 맞지 않은(non-balanced) 데이터 구조를 인덱싱 하는 데 유용하다.
포함되어야 하는 연산자 :
예제
GIN
GIN 인덱스는 배열, jsonb, range type과 같이 여러 복잡한 원소를 포함하는 데이터나 전체 텍스트 검색과 같은 데이터에 적합한 “역 인덱스”이다.
반전된 인덱스에는 각 구성 요서 값에 대한 별도의 항목이 포함되어 있으며, 특정 구성 요소 값이 있는지 테스트 하는 쿼리를 효과적으로 처리할 수 있다.
예를 들어 사용자가 검색 문자열 "raj"를 입력하면 Rajendra, Raju 및 Hansraj와 같은 이름에 대한 모든 행을 반환해야하는 경우 GIN 인덱스를 사용하기 좋다.
ST 및 SP-GiST와 마찬가지로 GIN은 다양한 사용자 정의 인덱싱 전략을 지원할 수 있으며 GIN 인덱스를 사용할 수 있는 특정 연산자는 인덱싱 전략에 따라 다르다.
아래의 연산자를 사용하여 인덱싱된 쿼리를 지원하는 배열용 GIN 연산자 클래스가 포함되어 있다.
예시
BRIN
BRIN indexes (a shorthand for Block Range INdexes) store summaries about the values stored in consecutive physical block ranges of a table.
Block Range INdexes의 줄임말인 BRIN 인덱스는 테이블의 물리 블록의 대한 값을 요약(최대값 , 최소값, 페이지 번호) 저장해두는 인덱스를 말한다.
만약 페이지 번호가 수정되지 않는다면 BRIN 값은 동일하게 유지된다.
테이블 행의 물리적 순서와 상관 관계가 좋은 값에 효과적이다.
GiST, SP-GiST 및 GIN과 마찬가지로 BRIN은 다양한 인덱싱 전략을 지원할 수 있으며 BRIN 인덱스를 사용할 수 있는 특정 연산자는 인덱싱 전략에 따라 다르다.
선형 정렬 순서가 있는 데이터(타임스탬프, 온도) 유형의 경우, 인덱싱된 데이터는 열의 최소값 및 최대값 사이의 블록 범위에 해당한다. 또한 이 경우 b-tree 인덱스에 비해 스토리지를 덜 사용한다.
예제
List indexes
Guidelines
The default Postgres index is a B-tree index.
You should always properly analyze your workload using query execution plans to determine the suitable Postgres index type.
Always create indexes on the most executed and costly queries. Avoid creating an index to satisfy a specific query.
As per best practice, always define a primary or unique key in a Postgres table. It automatically creates the B-tree index.
Avoid creating multiple indexes on a single column. It is better to look at which index is appropriate for your workload and drop the unnecessary indexes.
There is no specific limit on the number of indexes in the table; however, try to create the minimum indexes satisfying your workload.
목차
B-tree
B-tree is the default index in Postgres.
특정 값 검색, 스캔 범위, 데이터 정렬, 패턴 일치에 적합하다. Postgres에서 인덱스 유형을 지정하지 않으면 Lehman & Yao Algorithm and B+Trees 알고리즘을 따른다.
쿼리 플래너가 인덱싱된 열이 다음 연산자 중 하나를 사용하는 비교에 포함될 때 마다 B-tree 인덱스 사용을 고려한다.
between, in, is null, is not null 등의 조건과 함께 B트리 인덱스와 함께 사용할 수 있다.
B-트리 인덱스는 정렬된 순서로 데이터를 검색하는 데에도 사용할 수 있다. 이것은 단순한 스캔 및 정렬보다 항상 빠르지는 않지만 종종 도움이 된다.
인덱스에 사용 가능 연산자 : < <= = >= >
Hash
Hash indexes store a 32-bit hash code derived from the value of the indexed column.
해시 인덱스는 단순 일치(동등성) 비교를 처리하기 적합하다. 해시 인덱스가 된 열을 사용 할 경우 쿼리 플래너는 인덱싱된 열이 등호 연산자를 사용하는 exact match에 포함될 때 마다 해시 인덱스 사용을 고려한다.
인덱스에 사용 가능 연산자 : =
예제
GiST
GiST indexes are not a single kind of index, but rather an infrastructure within which many different indexing strategies can be implemented.
GiST(Generalized Search Tree) 인덱스는 인덱스이 종류라기 보단 인덱싱 전략에 도움이 되는 인프라 구조라 할 수 있다.
GiST 인덱스를 사용할 수 있는 특정 연산자는 인덱싱 전략(연산자 클래스)에 따라 다르다. 가령, PostgreSQL의 표준 배포에는 다음 연산자를 사용하여 여러 2차원 기하학적 데이터 유형을 인덱싱 할 수 있다.
또한 B-트리 또는 R-트리와 같은 다양한 전략을 구현할 수도 있다.
포함되어야 하는 연산자 :
예제
SP-GiST
SP-GiST indexes, like GiST indexes, offer an infrastructure that supports various kinds of searches.
SP-GiST는 다양한 비균형 디스크(non-balanced) 기반 데이터 구조(quadtree, k-d tree, radix tree) 구현을 허용한다.
공간 분리 GiST 인덱스를 통해 분할된 검색 트리를 활용하여 균형이 맞지 않은(non-balanced) 데이터 구조를 인덱싱 하는 데 유용하다.
포함되어야 하는 연산자 :
예제
GIN