[Pgday.Seoul 2017] 6. GIN vs GiST 인덱스 이야기 - 박진우

PgDay.Seoul
PgDay.SeoulPgDay.Seoul
GIN vs. GiST 인덱스 이야기
가이아쓰리디㈜
박진우(swat018@gmail.com)
2017. 11. 04
Contents
1.Index
2.Heap
3.Btree and GIN
4.Ttree and GiST
5.summary
Why Index??
Why Index??
Spatial
Index
Visibility
Index
Full Text
Search
Index
Index
Index
인덱스는 지정된 컬럼에 대한 매핑 정보를 가지고 있습니다.
Ex) CREATE INDEX test1_id_index ON test1 (id);
Index
PostgreSQL에서는 다음과 같은 Index type을 지원합니다.
• B-Tree : numbers, text, dates, etc..
• Generalized Inverted Index (GIN)
• Generalized Inverted Search Tree (GiST)
• Space partitioned GiST (SP-GiST)
• Block Range Indexes (BRIN)
• Hash
Heap
Heap(힙) 이란?
: 정렬의 기준이 없이 저장된 테이블의 존재 형태
Block 0
Block 1
Block 2
Block 3
Block 4
Block 0
Block 1
Block 2
Block 3
Block 4
0
1
2
3
0
1
2
3
0
1
2
3
0
1
2
3
0
1
2
3
Heap
Block 0
Block 1
Block 2
Block 3
Block 4
0
1
2
3
0
1
2
3
0
1
2
3
0
1
2
3
0
1
2
3
TID: Physical location of heap tuple
ex) Berlin: 0번째 Block의 2번째 항목이다.
Item Point: Berlin  (0,2)
Heap
• Table file은 n개의 block으로 구성되어 있다.
• 한 block 당 Page의 디폴트 크기는 8192byte(약 8KB)이다.
• 한 페이지(Page)는 Header Info, Record data, free space로 구성되어 있다.
Heap
Seq. Scan VS. Index Scan
B-tree
Postgres=# CREATE INDEX indexname ON tablename (columnname)
CREATE INDEX test1_id_index ON test1 (id);
• 기본적인 Index type의 방식
• 사용법
B-tree
B-tree
GIN
Seoul
(0,12)
Seoul
(4,2)
Seoul
(1,9)
Seoul
(4,1)
Busan
(2,2)
Seoul
(0,12), (4,2),
(1,9), (4,1),
(2,2)
Busan
(2,2)
Posing list
• Generalized Inverted Index (GIN)
GIN
Posting tree
GIN
Posting list
GIN
1. Text retrival
postgres=# -- create a table with a text column
postgres=# CREATE TABLE t1 (id serial, t text);
CREATE TABLE
postgres=# CREATE INDEX t1_idx ON t1 USING gin (to_tsvector('english', t));
CREATE INDEX
postgres=# INSERT INTO t1 VALUES (1, 'a fat cat sat on a mat and ate a fat rat');
INSERT 0 1
postgres=# INSERT INTO t1 VALUES (2, 'a fat dog sat on a mat and ate a fat chop');
INSERT 0 1
postgres=# -- is there a row where column t contains the two words? (syntax contains some magic
to hit index)
postgres=# SELECT * FROM t1 WHERE to_tsvector('english', t) @@ to_tsquery('fat & rat');
id | t
----+------------------------------------------
1 | a fat cat sat on a mat and ate a fat rat
(1 row)
postgres=# CREATE INDEX indexname ON tablename USING GIN (columnname);
GIN
2. Array
postgres=# -- create a table where one column exists of an integer array
postgres=# --
postgres=# CREATE TABLE t2 (id serial, temperatures INTEGER[]);
CREATE TABLE
postgres=# CREATE INDEX t2_idx ON t2 USING gin (temperatures);
CREATE INDEX
postgres=# INSERT INTO t2 VALUES (1, '{11, 12, 13, 14}');
INSERT 0 1
postgres=# INSERT INTO t2 VALUES (2, '{21, 22, 23, 24}');
INSERT 0 1
postgres=# -- Is there a row with the two array elements 12 and 11?
postgres=# SELECT * FROM t2 WHERE temperatures @> '{12, 11}';
id | temperatures
----+---------------
1 | {11,12,13,14}
(1 row)
GiST
• “contains”, “left of”, “overlaps”, 등을 지원한다.
• Full Text Search, Geometric operations (PostGIS, etc. ), Handling ranges (tiem, etc.)
• KNN-search, BRTree를 바탕으로 구성되어 있다.
R-tree(Rectangle-tree)
R-tree(Rectangle-tree)
Linear Indexing
R-tree(Rectangle-tree)
Multi-Dimensional
R-tree(Rectangle-tree)
Multi-Dimensional
GiST
postgres=# CREATE INDEX indexname ON tablename USING GIST
(columnname);
postgres=# -- create a table with a column of non-trivial type
postgres=# --
postgres=# CREATE TABLE t3 (id serial, c circle);
CREATE TABLE
postgres=# CREATE INDEX t3_idx ON t3 USING gist(c);
CREATE INDEX
postgres=# INSERT INTO t3 VALUES (1, circle '((0, 0), 0.5)');
INSERT 0 1
postgres=# INSERT INTO t3 VALUES (2, circle '((1, 0), 0.5)');
INSERT 0 1
postgres=# INSERT INTO t3 VALUES (3, circle '((0.3, 0.3), 0.3)');
INSERT 0 1
postgres=# -- which circles lie in the bounds of the unit circle?
postgres=# SELECT * FROM t3 WHERE circle '((0, 0), 1)' @> c;
id | c
----+-----------------
1 | <(0,0),0.5>
3 | <(0.3,0.3),0.3>
(2 rows)
지원하는 Data type
지원하는 Data type
지원하는 Data type
summary
• B-tree is ideal for unique values
• GIN is ideal for indexes with many duplicates
• GIST for everything else
Experiments lead to the following observations:
creation time - GIN takes 3x time to build than GiST
size of index - GIN is 2-3 times bigger than GiST
search time - GIN is 3 times faster than GiST
update time - GIN is about 10 times slower than GiST
경청해 주셔서 감사합니다.
swat018@gmail.com
1 of 32

Recommended

LX 공간정보아카데미 PostGIS 강의자료 by
LX 공간정보아카데미 PostGIS 강의자료LX 공간정보아카데미 PostGIS 강의자료
LX 공간정보아카데미 PostGIS 강의자료JungHwan Yun
3.7K views161 slides
[Pgday.Seoul 2020] SQL Tuning by
[Pgday.Seoul 2020] SQL Tuning[Pgday.Seoul 2020] SQL Tuning
[Pgday.Seoul 2020] SQL TuningPgDay.Seoul
1.2K views44 slides
PostGIS 시작하기 by
PostGIS 시작하기PostGIS 시작하기
PostGIS 시작하기Byeong-Hyeok Yu
7.9K views51 slides
[pgday.Seoul 2022] POSTGRES 테스트코드로 기여하기 - 이동욱 by
[pgday.Seoul 2022] POSTGRES 테스트코드로 기여하기 - 이동욱[pgday.Seoul 2022] POSTGRES 테스트코드로 기여하기 - 이동욱
[pgday.Seoul 2022] POSTGRES 테스트코드로 기여하기 - 이동욱PgDay.Seoul
178 views30 slides
PostgreSQL 튜닝워크샵 (2017년8월) by
PostgreSQL 튜닝워크샵 (2017년8월)PostgreSQL 튜닝워크샵 (2017년8월)
PostgreSQL 튜닝워크샵 (2017년8월)DBdemy
10.9K views207 slides
Postgresql by
PostgresqlPostgresql
PostgresqlNexThoughts Technologies
3.6K views20 slides

More Related Content

What's hot

PostgreSQL Performance Tables Partitioning vs. Aggregated Data Tables by
PostgreSQL Performance Tables Partitioning vs. Aggregated Data TablesPostgreSQL Performance Tables Partitioning vs. Aggregated Data Tables
PostgreSQL Performance Tables Partitioning vs. Aggregated Data TablesSperasoft
20.2K views20 slides
Deep dive into PostgreSQL statistics. by
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Alexey Lesovsky
22.9K views53 slides
Introduction to PostgreSQL by
Introduction to PostgreSQLIntroduction to PostgreSQL
Introduction to PostgreSQLJoel Brewer
881 views33 slides
[2019] 200만 동접 게임을 위한 MySQL 샤딩 by
[2019] 200만 동접 게임을 위한 MySQL 샤딩[2019] 200만 동접 게임을 위한 MySQL 샤딩
[2019] 200만 동접 게임을 위한 MySQL 샤딩NHN FORWARD
545 views50 slides
Indexes in postgres by
Indexes in postgresIndexes in postgres
Indexes in postgresLouise Grandjonc
1.3K views64 slides
Advanced pg_stat_statements: Filtering, Regression Testing & more by
Advanced pg_stat_statements: Filtering, Regression Testing & moreAdvanced pg_stat_statements: Filtering, Regression Testing & more
Advanced pg_stat_statements: Filtering, Regression Testing & moreLukas Fittl
2.7K views71 slides

What's hot(20)

PostgreSQL Performance Tables Partitioning vs. Aggregated Data Tables by Sperasoft
PostgreSQL Performance Tables Partitioning vs. Aggregated Data TablesPostgreSQL Performance Tables Partitioning vs. Aggregated Data Tables
PostgreSQL Performance Tables Partitioning vs. Aggregated Data Tables
Sperasoft20.2K views
Deep dive into PostgreSQL statistics. by Alexey Lesovsky
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
Alexey Lesovsky22.9K views
Introduction to PostgreSQL by Joel Brewer
Introduction to PostgreSQLIntroduction to PostgreSQL
Introduction to PostgreSQL
Joel Brewer881 views
[2019] 200만 동접 게임을 위한 MySQL 샤딩 by NHN FORWARD
[2019] 200만 동접 게임을 위한 MySQL 샤딩[2019] 200만 동접 게임을 위한 MySQL 샤딩
[2019] 200만 동접 게임을 위한 MySQL 샤딩
NHN FORWARD545 views
Advanced pg_stat_statements: Filtering, Regression Testing & more by Lukas Fittl
Advanced pg_stat_statements: Filtering, Regression Testing & moreAdvanced pg_stat_statements: Filtering, Regression Testing & more
Advanced pg_stat_statements: Filtering, Regression Testing & more
Lukas Fittl2.7K views
Pgday bdr 천정대 by PgDay.Seoul
Pgday bdr 천정대Pgday bdr 천정대
Pgday bdr 천정대
PgDay.Seoul1.6K views
PostgreSQL WAL for DBAs by PGConf APAC
PostgreSQL WAL for DBAs PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs
PGConf APAC4.6K views
PostgreSQL Advanced Queries by Nur Hidayat
PostgreSQL Advanced QueriesPostgreSQL Advanced Queries
PostgreSQL Advanced Queries
Nur Hidayat3.6K views
[pgday.Seoul 2022] 서비스개편시 PostgreSQL 도입기 - 진소린 & 김태정 by PgDay.Seoul
[pgday.Seoul 2022] 서비스개편시 PostgreSQL 도입기 - 진소린 & 김태정[pgday.Seoul 2022] 서비스개편시 PostgreSQL 도입기 - 진소린 & 김태정
[pgday.Seoul 2022] 서비스개편시 PostgreSQL 도입기 - 진소린 & 김태정
PgDay.Seoul188 views
공간정보거점대학 PostGIS 고급과정 by JungHwan Yun
공간정보거점대학 PostGIS 고급과정공간정보거점대학 PostGIS 고급과정
공간정보거점대학 PostGIS 고급과정
JungHwan Yun19.7K views
[Pgday.Seoul 2017] 1. PostGIS의 사례로 본 PostgreSQL 확장 - 장병진 by PgDay.Seoul
[Pgday.Seoul 2017] 1. PostGIS의 사례로 본 PostgreSQL 확장 - 장병진[Pgday.Seoul 2017] 1. PostGIS의 사례로 본 PostgreSQL 확장 - 장병진
[Pgday.Seoul 2017] 1. PostGIS의 사례로 본 PostgreSQL 확장 - 장병진
PgDay.Seoul2.4K views
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스 by PgDay.Seoul
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
PgDay.Seoul1.5K views
PostgreSQL Performance Tuning by elliando dias
PostgreSQL Performance TuningPostgreSQL Performance Tuning
PostgreSQL Performance Tuning
elliando dias4.1K views
[Pgday.Seoul 2021] 1. 예제로 살펴보는 포스트그레스큐엘의 독특한 SQL by PgDay.Seoul
[Pgday.Seoul 2021] 1. 예제로 살펴보는 포스트그레스큐엘의 독특한 SQL[Pgday.Seoul 2021] 1. 예제로 살펴보는 포스트그레스큐엘의 독특한 SQL
[Pgday.Seoul 2021] 1. 예제로 살펴보는 포스트그레스큐엘의 독특한 SQL
PgDay.Seoul420 views
ClickHouse in Real Life. Case Studies and Best Practices, by Alexander Zaitsev by Altinity Ltd
ClickHouse in Real Life. Case Studies and Best Practices, by Alexander ZaitsevClickHouse in Real Life. Case Studies and Best Practices, by Alexander Zaitsev
ClickHouse in Real Life. Case Studies and Best Practices, by Alexander Zaitsev
Altinity Ltd3.8K views
Amazon DocumentDB vs MongoDB 의 내부 아키텍쳐 와 장단점 비교 by Amazon Web Services Korea
Amazon DocumentDB vs MongoDB 의 내부 아키텍쳐 와 장단점 비교Amazon DocumentDB vs MongoDB 의 내부 아키텍쳐 와 장단점 비교
Amazon DocumentDB vs MongoDB 의 내부 아키텍쳐 와 장단점 비교

Similar to [Pgday.Seoul 2017] 6. GIN vs GiST 인덱스 이야기 - 박진우

Полнотекстовый поиск в PostgreSQL за миллисекунды (Олег Бартунов, Александр К... by
Полнотекстовый поиск в PostgreSQL за миллисекунды (Олег Бартунов, Александр К...Полнотекстовый поиск в PostgreSQL за миллисекунды (Олег Бартунов, Александр К...
Полнотекстовый поиск в PostgreSQL за миллисекунды (Олег Бартунов, Александр К...Ontico
7.2K views54 slides
Postgres can do THAT? by
Postgres can do THAT?Postgres can do THAT?
Postgres can do THAT?alexbrasetvik
217 views77 slides
PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро... by
PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро...PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро...
PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро...pgdayrussia
2.7K views44 slides
Indexing by
IndexingIndexing
IndexingDavood Barfeh
10K views23 slides
Deep dive to PostgreSQL Indexes by
Deep dive to PostgreSQL IndexesDeep dive to PostgreSQL Indexes
Deep dive to PostgreSQL IndexesIbrar Ahmed
150 views32 slides
Queuing Sql Server: Utilise queues to increase performance in SQL Server by
Queuing Sql Server: Utilise queues to increase performance in SQL ServerQueuing Sql Server: Utilise queues to increase performance in SQL Server
Queuing Sql Server: Utilise queues to increase performance in SQL ServerNiels Berglund
3.5K views19 slides

Similar to [Pgday.Seoul 2017] 6. GIN vs GiST 인덱스 이야기 - 박진우(20)

Полнотекстовый поиск в PostgreSQL за миллисекунды (Олег Бартунов, Александр К... by Ontico
Полнотекстовый поиск в PostgreSQL за миллисекунды (Олег Бартунов, Александр К...Полнотекстовый поиск в PostgreSQL за миллисекунды (Олег Бартунов, Александр К...
Полнотекстовый поиск в PostgreSQL за миллисекунды (Олег Бартунов, Александр К...
Ontico7.2K views
PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро... by pgdayrussia
PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро...PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро...
PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро...
pgdayrussia2.7K views
Deep dive to PostgreSQL Indexes by Ibrar Ahmed
Deep dive to PostgreSQL IndexesDeep dive to PostgreSQL Indexes
Deep dive to PostgreSQL Indexes
Ibrar Ahmed150 views
Queuing Sql Server: Utilise queues to increase performance in SQL Server by Niels Berglund
Queuing Sql Server: Utilise queues to increase performance in SQL ServerQueuing Sql Server: Utilise queues to increase performance in SQL Server
Queuing Sql Server: Utilise queues to increase performance in SQL Server
Niels Berglund3.5K views
Indexing & query optimization by Jared Rosoff
Indexing & query optimizationIndexing & query optimization
Indexing & query optimization
Jared Rosoff1.8K views
2015-12-05 Александр Коротков, Иван Панченко - Слабо-структурированные данные... by HappyDev
2015-12-05 Александр Коротков, Иван Панченко - Слабо-структурированные данные...2015-12-05 Александр Коротков, Иван Панченко - Слабо-структурированные данные...
2015-12-05 Александр Коротков, Иван Панченко - Слабо-структурированные данные...
HappyDev266 views
Algorithm by sultanarun
AlgorithmAlgorithm
Algorithm
sultanarun1.3K views
The NoSQL store everyone ignored by Zohaib Hassan
The NoSQL store everyone ignoredThe NoSQL store everyone ignored
The NoSQL store everyone ignored
Zohaib Hassan145 views
Chapter 3 Built-in Data Structures, Functions, and Files .pptx by SovannDoeur
Chapter 3 Built-in Data Structures, Functions, and Files .pptxChapter 3 Built-in Data Structures, Functions, and Files .pptx
Chapter 3 Built-in Data Structures, Functions, and Files .pptx
SovannDoeur7 views
Типы данных JSONb, соответствующие индексы и модуль jsquery – Олег Бартунов, ... by Yandex
Типы данных JSONb, соответствующие индексы и модуль jsquery – Олег Бартунов, ...Типы данных JSONb, соответствующие индексы и модуль jsquery – Олег Бартунов, ...
Типы данных JSONb, соответствующие индексы и модуль jsquery – Олег Бартунов, ...
Yandex1.8K views
PostgreSQL Moscow Meetup - September 2014 - Oleg Bartunov and Alexander Korotkov by Nikolay Samokhvalov
PostgreSQL Moscow Meetup - September 2014 - Oleg Bartunov and Alexander KorotkovPostgreSQL Moscow Meetup - September 2014 - Oleg Bartunov and Alexander Korotkov
PostgreSQL Moscow Meetup - September 2014 - Oleg Bartunov and Alexander Korotkov
Nikolay Samokhvalov2.7K views
Database index by Riteshkiit
Database indexDatabase index
Database index
Riteshkiit1.3K views
Brixton Library Technology Initiative by Basil Bibi
Brixton Library Technology InitiativeBrixton Library Technology Initiative
Brixton Library Technology Initiative
Basil Bibi238 views
Indexing Complex PostgreSQL Data Types by Jonathan Katz
Indexing Complex PostgreSQL Data TypesIndexing Complex PostgreSQL Data Types
Indexing Complex PostgreSQL Data Types
Jonathan Katz17.1K views
MySQL 5.7 NF – JSON Datatype 활용 by I Goo Lee
MySQL 5.7 NF – JSON Datatype 활용MySQL 5.7 NF – JSON Datatype 활용
MySQL 5.7 NF – JSON Datatype 활용
I Goo Lee7.9K views
02 Arrays And Memory Mapping by Qundeel
02 Arrays And Memory Mapping02 Arrays And Memory Mapping
02 Arrays And Memory Mapping
Qundeel6K views

More from PgDay.Seoul

[pgday.Seoul 2022] PostgreSQL with Google Cloud by
[pgday.Seoul 2022] PostgreSQL with Google Cloud[pgday.Seoul 2022] PostgreSQL with Google Cloud
[pgday.Seoul 2022] PostgreSQL with Google CloudPgDay.Seoul
229 views49 slides
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization by
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
[Pgday.Seoul 2021] 2. Porting Oracle UDF and OptimizationPgDay.Seoul
238 views107 slides
[Pgday.Seoul 2020] 포스트그레스큐엘 자국어화 이야기 by
[Pgday.Seoul 2020] 포스트그레스큐엘 자국어화 이야기[Pgday.Seoul 2020] 포스트그레스큐엘 자국어화 이야기
[Pgday.Seoul 2020] 포스트그레스큐엘 자국어화 이야기PgDay.Seoul
498 views17 slides
[Pgday.Seoul 2019] AppOS 고성능 I/O 확장 모듈로 성능 10배 향상시키기 by
[Pgday.Seoul 2019] AppOS 고성능 I/O 확장 모듈로 성능 10배 향상시키기[Pgday.Seoul 2019] AppOS 고성능 I/O 확장 모듈로 성능 10배 향상시키기
[Pgday.Seoul 2019] AppOS 고성능 I/O 확장 모듈로 성능 10배 향상시키기PgDay.Seoul
940 views40 slides
[Pgday.Seoul 2019] Advanced FDW by
[Pgday.Seoul 2019] Advanced FDW[Pgday.Seoul 2019] Advanced FDW
[Pgday.Seoul 2019] Advanced FDWPgDay.Seoul
412 views30 slides
[Pgday.Seoul 2018] PostgreSQL 11 새 기능 소개 by
[Pgday.Seoul 2018]  PostgreSQL 11 새 기능 소개[Pgday.Seoul 2018]  PostgreSQL 11 새 기능 소개
[Pgday.Seoul 2018] PostgreSQL 11 새 기능 소개PgDay.Seoul
3K views13 slides

More from PgDay.Seoul(20)

[pgday.Seoul 2022] PostgreSQL with Google Cloud by PgDay.Seoul
[pgday.Seoul 2022] PostgreSQL with Google Cloud[pgday.Seoul 2022] PostgreSQL with Google Cloud
[pgday.Seoul 2022] PostgreSQL with Google Cloud
PgDay.Seoul229 views
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization by PgDay.Seoul
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
PgDay.Seoul238 views
[Pgday.Seoul 2020] 포스트그레스큐엘 자국어화 이야기 by PgDay.Seoul
[Pgday.Seoul 2020] 포스트그레스큐엘 자국어화 이야기[Pgday.Seoul 2020] 포스트그레스큐엘 자국어화 이야기
[Pgday.Seoul 2020] 포스트그레스큐엘 자국어화 이야기
PgDay.Seoul498 views
[Pgday.Seoul 2019] AppOS 고성능 I/O 확장 모듈로 성능 10배 향상시키기 by PgDay.Seoul
[Pgday.Seoul 2019] AppOS 고성능 I/O 확장 모듈로 성능 10배 향상시키기[Pgday.Seoul 2019] AppOS 고성능 I/O 확장 모듈로 성능 10배 향상시키기
[Pgday.Seoul 2019] AppOS 고성능 I/O 확장 모듈로 성능 10배 향상시키기
PgDay.Seoul940 views
[Pgday.Seoul 2019] Advanced FDW by PgDay.Seoul
[Pgday.Seoul 2019] Advanced FDW[Pgday.Seoul 2019] Advanced FDW
[Pgday.Seoul 2019] Advanced FDW
PgDay.Seoul412 views
[Pgday.Seoul 2018] PostgreSQL 11 새 기능 소개 by PgDay.Seoul
[Pgday.Seoul 2018]  PostgreSQL 11 새 기능 소개[Pgday.Seoul 2018]  PostgreSQL 11 새 기능 소개
[Pgday.Seoul 2018] PostgreSQL 11 새 기능 소개
PgDay.Seoul3K views
[Pgday.Seoul 2018] PostgreSQL 성능을 위해 개발된 라이브러리 OS 소개 apposha by PgDay.Seoul
[Pgday.Seoul 2018]  PostgreSQL 성능을 위해 개발된 라이브러리 OS 소개 apposha[Pgday.Seoul 2018]  PostgreSQL 성능을 위해 개발된 라이브러리 OS 소개 apposha
[Pgday.Seoul 2018] PostgreSQL 성능을 위해 개발된 라이브러리 OS 소개 apposha
PgDay.Seoul1.1K views
[Pgday.Seoul 2018] PostgreSQL Authentication with FreeIPA by PgDay.Seoul
[Pgday.Seoul 2018]  PostgreSQL Authentication with FreeIPA[Pgday.Seoul 2018]  PostgreSQL Authentication with FreeIPA
[Pgday.Seoul 2018] PostgreSQL Authentication with FreeIPA
PgDay.Seoul786 views
[Pgday.Seoul 2018] 이기종 DB에서 PostgreSQL로의 Migration을 위한 DB2PG by PgDay.Seoul
[Pgday.Seoul 2018]  이기종 DB에서 PostgreSQL로의 Migration을 위한 DB2PG[Pgday.Seoul 2018]  이기종 DB에서 PostgreSQL로의 Migration을 위한 DB2PG
[Pgday.Seoul 2018] 이기종 DB에서 PostgreSQL로의 Migration을 위한 DB2PG
PgDay.Seoul1.9K views
[Pgday.Seoul 2018] AWS Cloud 환경에서 PostgreSQL 구축하기 by PgDay.Seoul
[Pgday.Seoul 2018]  AWS Cloud 환경에서 PostgreSQL 구축하기[Pgday.Seoul 2018]  AWS Cloud 환경에서 PostgreSQL 구축하기
[Pgday.Seoul 2018] AWS Cloud 환경에서 PostgreSQL 구축하기
PgDay.Seoul1.2K views
[Pgday.Seoul 2018] Greenplum의 노드 분산 설계 by PgDay.Seoul
[Pgday.Seoul 2018]  Greenplum의 노드 분산 설계[Pgday.Seoul 2018]  Greenplum의 노드 분산 설계
[Pgday.Seoul 2018] Greenplum의 노드 분산 설계
PgDay.Seoul1.6K views
[Pgday.Seoul 2018] replacing oracle with edb postgres by PgDay.Seoul
[Pgday.Seoul 2018] replacing oracle with edb postgres[Pgday.Seoul 2018] replacing oracle with edb postgres
[Pgday.Seoul 2018] replacing oracle with edb postgres
PgDay.Seoul606 views
[Pgday.Seoul 2017] 5. 테드폴허브(올챙이) PostgreSQL 확장하기 - 조현종 by PgDay.Seoul
[Pgday.Seoul 2017] 5. 테드폴허브(올챙이) PostgreSQL 확장하기 - 조현종[Pgday.Seoul 2017] 5. 테드폴허브(올챙이) PostgreSQL 확장하기 - 조현종
[Pgday.Seoul 2017] 5. 테드폴허브(올챙이) PostgreSQL 확장하기 - 조현종
PgDay.Seoul434 views
[Pgday.Seoul 2017] 7. PostgreSQL DB Tuning 기업사례 - 송춘자 by PgDay.Seoul
[Pgday.Seoul 2017] 7. PostgreSQL DB Tuning 기업사례 - 송춘자[Pgday.Seoul 2017] 7. PostgreSQL DB Tuning 기업사례 - 송춘자
[Pgday.Seoul 2017] 7. PostgreSQL DB Tuning 기업사례 - 송춘자
PgDay.Seoul4.3K views
[Pgday.Seoul 2017] 4. Composite Type/JSON 파라미터를 활용한 TVP구현(with C#, JAVA) - 지현명 by PgDay.Seoul
[Pgday.Seoul 2017] 4. Composite Type/JSON 파라미터를 활용한 TVP구현(with C#, JAVA) - 지현명[Pgday.Seoul 2017] 4. Composite Type/JSON 파라미터를 활용한 TVP구현(with C#, JAVA) - 지현명
[Pgday.Seoul 2017] 4. Composite Type/JSON 파라미터를 활용한 TVP구현(with C#, JAVA) - 지현명
PgDay.Seoul572 views
[Pgday.Seoul 2017] 8. PostgreSQL 10 새기능 소개 - 김상기 by PgDay.Seoul
[Pgday.Seoul 2017] 8. PostgreSQL 10 새기능 소개 - 김상기[Pgday.Seoul 2017] 8. PostgreSQL 10 새기능 소개 - 김상기
[Pgday.Seoul 2017] 8. PostgreSQL 10 새기능 소개 - 김상기
PgDay.Seoul3.1K views
[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오 by PgDay.Seoul
[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오
[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오
PgDay.Seoul1.4K views
[Pgday.Seoul 2017] 2. PostgreSQL을 위한 리눅스 커널 최적화 - 김상욱 by PgDay.Seoul
[Pgday.Seoul 2017] 2. PostgreSQL을 위한 리눅스 커널 최적화 - 김상욱[Pgday.Seoul 2017] 2. PostgreSQL을 위한 리눅스 커널 최적화 - 김상욱
[Pgday.Seoul 2017] 2. PostgreSQL을 위한 리눅스 커널 최적화 - 김상욱
PgDay.Seoul931 views
PostgreSQL 9.6 새 기능 소개 by PgDay.Seoul
PostgreSQL 9.6 새 기능 소개PostgreSQL 9.6 새 기능 소개
PostgreSQL 9.6 새 기능 소개
PgDay.Seoul3.2K views
pg_hba.conf 이야기 by PgDay.Seoul
pg_hba.conf 이야기pg_hba.conf 이야기
pg_hba.conf 이야기
PgDay.Seoul831 views

Recently uploaded

DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h... by
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...Deltares
5 views31 slides
Copilot Prompting Toolkit_All Resources.pdf by
Copilot Prompting Toolkit_All Resources.pdfCopilot Prompting Toolkit_All Resources.pdf
Copilot Prompting Toolkit_All Resources.pdfRiccardo Zamana
8 views4 slides
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge... by
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...Deltares
17 views12 slides
SAP FOR CONTRACT MANUFACTURING.pdf by
SAP FOR CONTRACT MANUFACTURING.pdfSAP FOR CONTRACT MANUFACTURING.pdf
SAP FOR CONTRACT MANUFACTURING.pdfVirendra Rai, PMP
11 views2 slides
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra... by
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra....NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...Marc Müller
38 views62 slides
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports by
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug ReportsBushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug ReportsRa'Fat Al-Msie'deen
5 views49 slides

Recently uploaded(20)

DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h... by Deltares
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...
Deltares5 views
Copilot Prompting Toolkit_All Resources.pdf by Riccardo Zamana
Copilot Prompting Toolkit_All Resources.pdfCopilot Prompting Toolkit_All Resources.pdf
Copilot Prompting Toolkit_All Resources.pdf
Riccardo Zamana8 views
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge... by Deltares
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
Deltares17 views
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra... by Marc Müller
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra....NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
Marc Müller38 views
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports by Ra'Fat Al-Msie'deen
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug ReportsBushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
Generic or specific? Making sensible software design decisions by Bert Jan Schrijver
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated... by TomHalpin9
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
TomHalpin95 views
360 graden fabriek by info33492
360 graden fabriek360 graden fabriek
360 graden fabriek
info3349237 views
Software testing company in India.pptx by SakshiPatel82
Software testing company in India.pptxSoftware testing company in India.pptx
Software testing company in India.pptx
SakshiPatel827 views
Fleet Management Software in India by Fleetable
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India
Fleetable11 views
Navigating container technology for enhanced security by Niklas Saari by Metosin Oy
Navigating container technology for enhanced security by Niklas SaariNavigating container technology for enhanced security by Niklas Saari
Navigating container technology for enhanced security by Niklas Saari
Metosin Oy13 views
Tridens DevOps by Tridens
Tridens DevOpsTridens DevOps
Tridens DevOps
Tridens9 views
DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the... by Deltares
DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the...DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the...
DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the...
Deltares6 views
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J... by Deltares
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...
Deltares9 views
DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ... by Deltares
DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...
DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...
Deltares10 views
DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t... by Deltares
DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t...DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t...
DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t...
Deltares9 views
FIMA 2023 Neo4j & FS - Entity Resolution.pptx by Neo4j
FIMA 2023 Neo4j & FS - Entity Resolution.pptxFIMA 2023 Neo4j & FS - Entity Resolution.pptx
FIMA 2023 Neo4j & FS - Entity Resolution.pptx
Neo4j6 views

[Pgday.Seoul 2017] 6. GIN vs GiST 인덱스 이야기 - 박진우

  • 1. GIN vs. GiST 인덱스 이야기 가이아쓰리디㈜ 박진우(swat018@gmail.com) 2017. 11. 04
  • 7. Index 인덱스는 지정된 컬럼에 대한 매핑 정보를 가지고 있습니다. Ex) CREATE INDEX test1_id_index ON test1 (id);
  • 8. Index PostgreSQL에서는 다음과 같은 Index type을 지원합니다. • B-Tree : numbers, text, dates, etc.. • Generalized Inverted Index (GIN) • Generalized Inverted Search Tree (GiST) • Space partitioned GiST (SP-GiST) • Block Range Indexes (BRIN) • Hash
  • 9. Heap Heap(힙) 이란? : 정렬의 기준이 없이 저장된 테이블의 존재 형태 Block 0 Block 1 Block 2 Block 3 Block 4 Block 0 Block 1 Block 2 Block 3 Block 4 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3
  • 10. Heap Block 0 Block 1 Block 2 Block 3 Block 4 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 TID: Physical location of heap tuple ex) Berlin: 0번째 Block의 2번째 항목이다. Item Point: Berlin  (0,2)
  • 11. Heap • Table file은 n개의 block으로 구성되어 있다. • 한 block 당 Page의 디폴트 크기는 8192byte(약 8KB)이다. • 한 페이지(Page)는 Header Info, Record data, free space로 구성되어 있다.
  • 12. Heap
  • 13. Seq. Scan VS. Index Scan
  • 14. B-tree Postgres=# CREATE INDEX indexname ON tablename (columnname) CREATE INDEX test1_id_index ON test1 (id); • 기본적인 Index type의 방식 • 사용법
  • 20. GIN 1. Text retrival postgres=# -- create a table with a text column postgres=# CREATE TABLE t1 (id serial, t text); CREATE TABLE postgres=# CREATE INDEX t1_idx ON t1 USING gin (to_tsvector('english', t)); CREATE INDEX postgres=# INSERT INTO t1 VALUES (1, 'a fat cat sat on a mat and ate a fat rat'); INSERT 0 1 postgres=# INSERT INTO t1 VALUES (2, 'a fat dog sat on a mat and ate a fat chop'); INSERT 0 1 postgres=# -- is there a row where column t contains the two words? (syntax contains some magic to hit index) postgres=# SELECT * FROM t1 WHERE to_tsvector('english', t) @@ to_tsquery('fat & rat'); id | t ----+------------------------------------------ 1 | a fat cat sat on a mat and ate a fat rat (1 row) postgres=# CREATE INDEX indexname ON tablename USING GIN (columnname);
  • 21. GIN 2. Array postgres=# -- create a table where one column exists of an integer array postgres=# -- postgres=# CREATE TABLE t2 (id serial, temperatures INTEGER[]); CREATE TABLE postgres=# CREATE INDEX t2_idx ON t2 USING gin (temperatures); CREATE INDEX postgres=# INSERT INTO t2 VALUES (1, '{11, 12, 13, 14}'); INSERT 0 1 postgres=# INSERT INTO t2 VALUES (2, '{21, 22, 23, 24}'); INSERT 0 1 postgres=# -- Is there a row with the two array elements 12 and 11? postgres=# SELECT * FROM t2 WHERE temperatures @> '{12, 11}'; id | temperatures ----+--------------- 1 | {11,12,13,14} (1 row)
  • 22. GiST • “contains”, “left of”, “overlaps”, 등을 지원한다. • Full Text Search, Geometric operations (PostGIS, etc. ), Handling ranges (tiem, etc.) • KNN-search, BRTree를 바탕으로 구성되어 있다.
  • 27. GiST postgres=# CREATE INDEX indexname ON tablename USING GIST (columnname); postgres=# -- create a table with a column of non-trivial type postgres=# -- postgres=# CREATE TABLE t3 (id serial, c circle); CREATE TABLE postgres=# CREATE INDEX t3_idx ON t3 USING gist(c); CREATE INDEX postgres=# INSERT INTO t3 VALUES (1, circle '((0, 0), 0.5)'); INSERT 0 1 postgres=# INSERT INTO t3 VALUES (2, circle '((1, 0), 0.5)'); INSERT 0 1 postgres=# INSERT INTO t3 VALUES (3, circle '((0.3, 0.3), 0.3)'); INSERT 0 1 postgres=# -- which circles lie in the bounds of the unit circle? postgres=# SELECT * FROM t3 WHERE circle '((0, 0), 1)' @> c; id | c ----+----------------- 1 | <(0,0),0.5> 3 | <(0.3,0.3),0.3> (2 rows)
  • 31. summary • B-tree is ideal for unique values • GIN is ideal for indexes with many duplicates • GIST for everything else Experiments lead to the following observations: creation time - GIN takes 3x time to build than GiST size of index - GIN is 2-3 times bigger than GiST search time - GIN is 3 times faster than GiST update time - GIN is about 10 times slower than GiST