Nội dung
Danh sách bài học
- 01~18 phút
JSONB vs JSON vs TEXT — lưu trữ dữ liệu bán cấu trúc trong PostgreSQL
TEXT, JSON, JSONB: khi nào dùng loại nào, tại sao JSONB là lựa chọn mặc định 2025. Binary decompose, GIN index, demo custom field multi-tenant TaskFlow.
- 02~22 phút
JSONB operators & JSONPath — ->, ->>, @>, ?, jsonb_path_query
7 JSONB operator cốt lõi + JSONPath PG 12+: cách query nested field, containment, key existence trong TaskFlow custom metadata. Cast numeric, NULL handling, pitfall return type.
- 03~22 phút
GIN index cho JSONB — jsonb_ops vs jsonb_path_ops, partial GIN, write tax
WHERE task_metadata @> '{"priority":"high"}' trên 5M row = Seq Scan 3 giây. GIN inverted index cho JSONB: jsonb_ops vs jsonb_path_ops, partial GIN, expression GIN, bulk load pattern, gin_pending_list_limit.
- 04~20 phút
Hybrid schema — column cứng + JSONB, khi nào migrate, zero-downtime pattern
TaskFlow priority nên là column hay JSONB? Hybrid pattern: column cho common field, JSONB cho custom field. 8 bước migrate zero-downtime, audit key usage định kỳ, decision matrix.
- 05~25 phút
Full-text search tiếng Việt — tsvector, unaccent, GIN FTS trong PostgreSQL
WHERE body LIKE '%deploy%' scan 1M row mất 2.5 giây và không match 'deployment'. Search 'khẩn cấp' không match khi user gõ không dấu. Full-text search với tsvector + unaccent dictionary giải quyết cả hai — không cần Elasticsearch.
- 06~25 phút
pgvector + Text-to-SQL — semantic search và AI query trong PostgreSQL
pgvector v0.8, HNSW index, 3 distance operator, workflow embedding end-to-end với TaskFlow. Text-to-SQL teaser: LLM nhận schema + few-shot → generate SQL. Pitfall storage, hybrid search, model consistency.
- 07~30 phút
Mini-challenge M09 — TaskFlow advanced search: FTS + JSONB + pgvector trong 1 query
Build advanced search production-ready cho TaskFlow: combine 3 index (GIN FTS, GIN JSONB, B-tree due_at) trong 1 query Bitmap And, thêm pgvector semantic similarity và hybrid rerank manual. Bài cuối Tier 2.