heowc / programming-study

개발 스킬, 언어, 설계에 대한 공유 저장소
https://heowc.dev/programming-study/repo/
53 stars 5 forks source link

[db] postgres index (gin, gist) in json data type #120

Closed heowc closed 1 year ago

heowc commented 2 years ago
heowc commented 2 years ago

tsvector란?

heowc commented 2 years ago

docker run -d -it -p5432:5432 -e POSTGRES_PASSWORD=password postgres:14

heowc commented 2 years ago

json/jsonb란?

heowc commented 2 years ago
SELECT 'a fat cat sat on a mat and ate a fat rat'::tsvector;

select to_tsvector('{"a": "b"}'::jsonb);
select * from ts_debug('{"a": "b"}');

select to_tsvector('{"a": "b", "c": "d"}'::jsonb);
select * from ts_debug('{"a": "b", "c": "d"}');

select to_tsvector('{"a": "b", "c": "b"}'::jsonb);
select * from ts_debug('{"a": "b", "c": "b"}');

select to_tsvector('["a","c"]'::jsonb);
select * from ts_debug('["a","c"]');

select to_tsvector('["a","a"]'::jsonb);
select * from ts_debug('["a","a"]');
heowc commented 2 years ago

https://pganalyze.com/blog/gin-index https://boiler.buzzni.com/2017/02/27/postgresql-json-indexing.html https://boiler.buzzni.com/2017/03/31/postgresql-relation-model.html https://scalegrid.io/blog/using-jsonb-in-postgresql-how-to-effectively-store-index-json-data-in-postgresql/ https://bitnine.net/blog-postgresql/postgresql-internals-jsonb-type-and-its-indexes/

heowc commented 2 years ago
heowc commented 2 years ago

https://blog.goodusdata.com/197

heowc commented 2 years ago

https://www.postgresql.org/docs/current/functions-json.html