_CORE
AI & Agentic Systems Core Information Systems Cloud & Platform Engineering Data Platform & Integration Security & Compliance QA, Testing & Observability IoT, Automation & Robotics Mobile & Digital Banking & Finance Insurance Public Administration Defense & Security Healthcare Energy & Utilities Telco & Media Manufacturing Logistics & E-commerce Retail & Loyalty
References Technologies Blog Know-how Tools
About Collaboration Careers
CS EN
Let's talk

Database Indexing Strategie

14. 10. 2025 1 min read intermediate

Správný index zrychlí dotaz 1000x. Špatný index zabírá místo a zpomaluje zápisy.

Types indexů

  • B-tree: Default, equality a range queries
  • Hash: Jen equality (=)
  • GIN: JSONB, array, full-text search
  • GiST: Geometrie, range types
  • BRIN: Velké tabulky s přirozeným řazením

Strategies

– Composite index — pořadí sloupců! – Pravidlo: equality columns first, then range CREATE INDEX idx_orders ON orders(status, created_at DESC); – Covering index — index-only scan CREATE INDEX idx_users_cover ON users(email) INCLUDE (name, role); – Partial index — jen aktivní záznamy CREATE INDEX idx_active ON users(email) WHERE deleted_at IS NULL; – Analýza nepoužívaných indexů SELECT indexrelname, idx_scan FROM pg_stat_user_indexes WHERE idx_scan = 0 AND indexrelname NOT LIKE ‘%_pkey’;

Key Takeaway

Equality first v composite indexu. Partial pro subset, covering pro index-only scan. Odstraňte nepoužívané indexy.

databaseindexingpostgresqlperformance
Share:

CORE SYSTEMS tým

Stavíme core systémy a AI agenty, které drží provoz. 15 let zkušeností s enterprise IT.