[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6D1SMK4WS6TDZ973QAMT5QT":3,"skill-same:01M6D1SMK4WS6TDZ973QAMT5QT":61},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":33,"linkOnly":34,"markdownContent":35,"markdownBody":36,"frontMatter":37,"refName":38,"commitSha":39,"skillDirectory":40,"forksCount":41,"repositoryHtmlUrl":42,"repositoryHomepageUrl":43,"ownerHtmlUrl":44,"ownerBlogUrl":43,"ownerDescription":45,"updatedAt":46,"install":47,"resources":60},"01M6D1SMK4WS6TDZ973QAMT5QT","database-indexes",null,"Indexes that pay for themselves: B-tree by default, the order of columns in composite indexes, covering, partial and expression indexes, GIN for JSON, arrays, full text and trigrams, BRIN for time series, what each costs on writes, finding missing and unused ones, and creating them without locking. Read before adding, changing or removing an index.","enowdev\u002Fenowxcli","enowdev","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F179420349?v=4","01M6D1MVX2KC0X3Z9NESE7P22K","Enow Dev.","01M6D1MW1FMZGBDKWAJY4GQX81",67,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fenowdev\u002Fenowxcli\u002Fblob\u002Fmain\u002Fcrates\u002Fenowx-core\u002Fskills\u002Fdatabase-indexes\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32],"database","indexes","database indexes","index","time series","b-tree","json","text","read","default","arrays","time","full","series","2026-11-10 10:12:30",false,"---\nname: database-indexes\ndescription: \"Indexes that pay for themselves: B-tree by default, the order of columns in composite indexes, covering, partial and expression indexes, GIN for JSON, arrays, full text and trigrams, BRIN for time series, what each costs on writes, finding missing and unused ones, and creating them without locking. Read before adding, changing or removing an index.\"\n---\n\n# Indexes\n\nThe generated version: an index on every column one by one, none on the pair\nthe hot query filters by, `(created_at, customer_id)` for a query that\nfilters by customer, a GIN index on a `jsonb` column nobody queries with\n`@>`, a boolean indexed alone, a foreign key without an index so deleting a\ncustomer scans the orders table, and every index built with a plain\n`CREATE INDEX` that blocks writes while it runs. An index is a sorted copy of\nsome columns: it makes certain reads fast and every write slower. This skill\nis choosing the few that pay. Query shape is in `database-queries`. Examples\nare PostgreSQL unless marked.\n\n## 1. Start from the queries\n\n- List the queries that matter: those on every request, the slowest by total\n  time (`pg_stat_statements`), those behind a timeout. For each, note the\n  equality columns, range columns, join keys, `ORDER BY` and `LIMIT`.\n- `EXPLAIN (ANALYZE, BUFFERS)` before, create the index, `EXPLAIN` after;\n  keep it only when the plan uses it and time or buffers drop. Test on\n  realistic volumes: under a few thousand rows a sequential scan is right,\n  and the planner ignores your index.\n- One composite index often serves several queries; extending an existing\n  index beats adding another.\n\n## 2. B-tree and column order\n\nB-tree is the default and serves `=`, `\u003C`, `>`, `BETWEEN`, `IN`, `IS NULL`,\nprefix `LIKE`, and `ORDER BY` in either direction.\n\n- Equality columns first, then one range or sort column:\n\n```sql\n-- WHERE tenant_id = $1 AND status = $2 ORDER BY created_at DESC LIMIT 50\nCREATE INDEX CONCURRENTLY idx_orders_tenant_id_status_created_at\n  ON orders (tenant_id, status, created_at);\n```\n\n  It is read backwards for `DESC`; declare directions only for mixed sorts\n  (`ORDER BY priority DESC, created_at` wants `(priority DESC, created_at)`).\n- After a range condition the next columns cannot narrow the scan: for\n  `WHERE customer_id = $1 AND created_at > $2`, `(customer_id, created_at)`\n  is right and `(created_at, customer_id)` walks the whole range.\n- Leftmost prefix: `(a, b, c)` serves filters on `a`, `a, b` and `a, b, c`,\n  not `b` alone. Skip scan (Postgres 18, MySQL 8.0.13+) can use it for `b`\n  when `a` has few distinct values; do not design for it.\n- Among equality columns, lead with the one most queries share (`tenant_id`,\n  the parent id), so the index serves them all.\n- End with `id` for keyset pagination: `(customer_id, created_at, id)`.\n\n## 3. Covering, partial, expression, unique\n\n- **Covering** (`INCLUDE`, Postgres 11+) for index-only scans, which read no\n  table pages while the visibility map is current (vacuum keeps it so):\n\n```sql\nCREATE INDEX CONCURRENTLY idx_orders_customer_id_created_at\n  ON orders (customer_id, created_at) INCLUDE (status, total_cents);\n```\n\n  MySQL secondary indexes carry the primary key already; add other columns\n  to the key.\n- **Partial**: only the rows you query, so smaller and cheaper to keep:\n\n```sql\nCREATE INDEX CONCURRENTLY idx_jobs_queued_run_at ON jobs (run_at) WHERE status = 'queued';\nCREATE UNIQUE INDEX CONCURRENTLY users_email_live_key\n  ON users (lower(email)) WHERE deleted_at IS NULL;\n```\n\n  The query must repeat the condition as written, with a constant rather\n  than a parameter. MySQL has no partial indexes (index a generated column\n  that is NULL for the rows to skip); SQLite has them.\n- **Expression**: index what the query computes. `ON users (lower(email))`\n  serves `WHERE lower(email) = $1`, that exact expression; MySQL 8.0.13+\n  writes `INDEX ((lower(email)))`. The expression must be immutable, so\n  `date(created_at)` on a `timestamptz` is refused: filter by a range.\n- **Unique**: prefer a constraint (`UNIQUE (shop_id, sku)`), which shows in\n  the schema and can be the target of a foreign key; a unique index for\n  partial and expression rules.\n\n## 4. The other index types (Postgres)\n\n| Type | For | Example |\n|---|---|---|\n| GIN | `jsonb` containment and keys, arrays, full text, trigrams | `USING gin (tags)` |\n| GiST | Ranges and overlaps, exclusion constraints, geometry, nearest neighbour | `USING gist (during)` |\n| BRIN | Huge append-only tables whose column follows insert order | `USING brin (created_at)` |\n| HNSW (pgvector) | Vector similarity (`database-postgres`) | `USING hnsw (embedding vector_cosine_ops)` |\n| Hash | Equality only | Rarely better than B-tree |\n\n- `jsonb`: `jsonb_path_ops` is smaller and faster but serves only `@>`,\n  `@?` and `@@`; the default `jsonb_ops` also serves key existence (`?`).\n  One key compared by equality is better served by a B-tree expression:\n\n```sql\nCREATE INDEX CONCURRENTLY idx_events_payload ON events USING gin (payload jsonb_path_ops);\n-- WHERE payload @> '{\"type\": \"refund\"}'\nCREATE INDEX CONCURRENTLY idx_events_customer_id ON events ((payload ->> 'customer_id'));\n-- WHERE payload ->> 'customer_id' = $1\n```\n\n- Full text: a stored generated `tsvector` column with GIN, queried with\n  `search @@ websearch_to_tsquery('english', $1)`. Adding a stored column\n  rewrites the table, so on a big one it is a migration step of its own:\n\n```sql\nALTER TABLE articles ADD COLUMN search tsvector GENERATED ALWAYS AS\n  (to_tsvector('english', coalesce(title, '') || ' ' || coalesce(body, ''))) STORED;\nCREATE INDEX CONCURRENTLY idx_articles_search ON articles USING gin (search);\n```\n\n- Substring and fuzzy search (`ILIKE '%term%'`, similarity with `%`):\n  `CREATE EXTENSION pg_trgm;` then\n  `CREATE INDEX CONCURRENTLY idx_products_name_trgm ON products USING gin (name gin_trgm_ops);`.\n  It helps from three characters of search term up.\n- BRIN is kilobytes for billions of rows and helps only while physical order\n  follows the column (append-only events by `created_at`); on tables that\n  are updated or reordered it does nothing.\n- GIN writes are expensive; its pending list (`fastupdate`) defers them at\n  some cost to reads. Measure before adding GIN to a write-heavy table.\n\n## 5. What each index costs\n\n- Every insert writes every index. In Postgres an update that changes a\n  column in any B-tree index loses the HOT path (updating in place without\n  touching indexes) and writes every index of the table: an index on a hot\n  table's `updated_at` does that to every update.\n- Indexes compete with table data for memory; a table whose indexes are\n  bigger than its data is a smell. Vacuum, backups, restores and replication\n  carry them all.\n- Low selectivity alone is useless: `is_active` true for 95% of rows is\n  never used for `true`. If the rare value is what you query, a partial\n  index on it.\n- Update-heavy tables leave room for HOT updates with\n  `ALTER TABLE counters SET (fillfactor = 90);` (new pages; a rewrite\n  applies it to all).\n\n## 6. Foreign keys need indexes\n\nPostgres indexes the referenced key (it is unique) but not the referencing\ncolumn. Without that index a join from the parent scans the child, and each\ndelete or key update on the parent scans the child while holding locks.\nInnoDB creates one automatically. Single-column foreign keys without an\nindex whose first column matches:\n\n```sql\nSELECT c.conrelid::regclass AS table_name, c.conname, a.attname AS column_name\nFROM pg_constraint c\nJOIN pg_attribute a ON a.attrelid = c.conrelid AND a.attnum = c.conkey[1]\nWHERE c.contype = 'f' AND cardinality(c.conkey) = 1\n  AND NOT EXISTS (\n    SELECT 1 FROM pg_index i\n    WHERE i.indrelid = c.conrelid AND i.indkey[0] = c.conkey[1]\n  );\n```\n\n## 7. Missing, unused, duplicate\n\n- Missing: the top of `pg_stat_statements` by `total_exec_time`, and big\n  tables read by sequential scans:\n\n```sql\nSELECT relname, seq_scan, seq_tup_read, idx_scan, n_live_tup\nFROM pg_stat_user_tables\nWHERE n_live_tup > 100000\nORDER BY seq_tup_read DESC LIMIT 20;\n```\n\n  `auto_explain` with `auto_explain.log_min_duration = '500ms'` logs the\n  plans of slow statements. MySQL: `sys.statements_with_full_table_scans`\n  and the slow log.\n- Unused: not scanned since statistics were reset, over a window that\n  includes month-end jobs:\n\n```sql\nSELECT s.relname, s.indexrelname, s.idx_scan,\n       pg_size_pretty(pg_relation_size(s.indexrelid)) AS size\nFROM pg_stat_user_indexes s\nJOIN pg_index i ON i.indexrelid = s.indexrelid\nWHERE s.idx_scan = 0 AND NOT i.indisunique AND NOT i.indisprimary\nORDER BY pg_relation_size(s.indexrelid) DESC;\n```\n\n  Statistics are per server: check replicas before dropping, since reports\n  may use an index only there. MySQL: `sys.schema_unused_indexes`; make it\n  invisible first (`ALTER TABLE orders ALTER INDEX idx_x INVISIBLE`), drop it\n  after a quiet week.\n- Duplicates: two indexes on the same columns, or `(a)` beside `(a, b)`,\n  where the second serves both unless `(a)` is unique. MySQL:\n  `sys.schema_redundant_indexes`.\n- Bloat after heavy updates or deletes: `pgstatindex()` from `pgstattuple`\n  measures it; `REINDEX INDEX CONCURRENTLY` (Postgres 12+) rebuilds without\n  blocking.\n\n## 8. Creating and dropping on a live table\n\n- Postgres: `CREATE INDEX CONCURRENTLY` and `DROP INDEX CONCURRENTLY`,\n  outside a transaction, through the migration tool's no-transaction mode\n  (`database-migrations`). Two table scans and a wait for older\n  transactions make it slower, but writes continue. A failed build leaves an\n  `INVALID` index to drop and rebuild. `SET maintenance_work_mem = '1GB'` in\n  the session speeds up a big build.\n- MySQL: `ALTER TABLE orders ADD INDEX idx_x (col), ALGORITHM=INPLACE,\n  LOCK=NONE;` is online; on the largest tables gh-ost spares the replicas.\n- SQLite: `CREATE INDEX` blocks writers while it runs; seconds for a few\n  gigabytes, so run it at a quiet moment.\n- MongoDB builds indexes without blocking since 4.2 (`database-mongodb`).\n\n## 9. MySQL and SQLite notes\n\n- InnoDB is clustered on the primary key: rows are stored in its order and\n  every secondary index entry carries it. A wide key (a UUID string) bloats\n  every index; a random one scatters inserts (`database-mysql`).\n- MySQL prefix indexes (`INDEX (title(50))`) for long strings cannot cover a\n  query or serve `ORDER BY`; keys are limited to 3,072 bytes (768\n  `utf8mb4` characters).\n- Histograms help filters on unindexed columns:\n  `ANALYZE TABLE orders UPDATE HISTOGRAM ON status;`.\n- SQLite: confirm with `EXPLAIN QUERY PLAN`, keep statistics with\n  `PRAGMA optimize`; partial and expression indexes are supported.\n\n## Check it\n\n- `EXPLAIN (ANALYZE, BUFFERS)` of each target query before and after, on\n  realistic volumes: the new index is in the plan and time or buffers\n  dropped. If it is not in the plan, drop it.\n- The build used `CONCURRENTLY` or the engine's online form, and\n  `SELECT indexrelid::regclass FROM pg_index WHERE NOT indisvalid;` returns\n  nothing.\n- The foreign key query in section 6 lists nothing new.\n- A week after release: the new index's `idx_scan` climbs and write latency\n  on the table did not jump.\n\n## Avoid\n\nAn index per column; the range column first in a composite; indexes no plan\nuses; a boolean indexed alone; foreign keys without an index in Postgres;\n`CREATE INDEX` without `CONCURRENTLY` on a live table; GIN on `jsonb` for\nqueries that never use `@>`; dropping an unused index without checking the\nreplicas and the monthly jobs; an index on a hot table's `updated_at` with\nno query that needs it; an index judged on a table of 100 rows.\n","# Indexes\n\nThe generated version: an index on every column one by one, none on the pair\nthe hot query filters by, `(created_at, customer_id)` for a query that\nfilters by customer, a GIN index on a `jsonb` column nobody queries with\n`@>`, a boolean indexed alone, a foreign key without an index so deleting a\ncustomer scans the orders table, and every index built with a plain\n`CREATE INDEX` that blocks writes while it runs. An index is a sorted copy of\nsome columns: it makes certain reads fast and every write slower. This skill\nis choosing the few that pay. Query shape is in `database-queries`. Examples\nare PostgreSQL unless marked.\n\n## 1. Start from the queries\n\n- List the queries that matter: those on every request, the slowest by total\n  time (`pg_stat_statements`), those behind a timeout. For each, note the\n  equality columns, range columns, join keys, `ORDER BY` and `LIMIT`.\n- `EXPLAIN (ANALYZE, BUFFERS)` before, create the index, `EXPLAIN` after;\n  keep it only when the plan uses it and time or buffers drop. Test on\n  realistic volumes: under a few thousand rows a sequential scan is right,\n  and the planner ignores your index.\n- One composite index often serves several queries; extending an existing\n  index beats adding another.\n\n## 2. B-tree and column order\n\nB-tree is the default and serves `=`, `\u003C`, `>`, `BETWEEN`, `IN`, `IS NULL`,\nprefix `LIKE`, and `ORDER BY` in either direction.\n\n- Equality columns first, then one range or sort column:\n\n```sql\n-- WHERE tenant_id = $1 AND status = $2 ORDER BY created_at DESC LIMIT 50\nCREATE INDEX CONCURRENTLY idx_orders_tenant_id_status_created_at\n  ON orders (tenant_id, status, created_at);\n```\n\n  It is read backwards for `DESC`; declare directions only for mixed sorts\n  (`ORDER BY priority DESC, created_at` wants `(priority DESC, created_at)`).\n- After a range condition the next columns cannot narrow the scan: for\n  `WHERE customer_id = $1 AND created_at > $2`, `(customer_id, created_at)`\n  is right and `(created_at, customer_id)` walks the whole range.\n- Leftmost prefix: `(a, b, c)` serves filters on `a`, `a, b` and `a, b, c`,\n  not `b` alone. Skip scan (Postgres 18, MySQL 8.0.13+) can use it for `b`\n  when `a` has few distinct values; do not design for it.\n- Among equality columns, lead with the one most queries share (`tenant_id`,\n  the parent id), so the index serves them all.\n- End with `id` for keyset pagination: `(customer_id, created_at, id)`.\n\n## 3. Covering, partial, expression, unique\n\n- **Covering** (`INCLUDE`, Postgres 11+) for index-only scans, which read no\n  table pages while the visibility map is current (vacuum keeps it so):\n\n```sql\nCREATE INDEX CONCURRENTLY idx_orders_customer_id_created_at\n  ON orders (customer_id, created_at) INCLUDE (status, total_cents);\n```\n\n  MySQL secondary indexes carry the primary key already; add other columns\n  to the key.\n- **Partial**: only the rows you query, so smaller and cheaper to keep:\n\n```sql\nCREATE INDEX CONCURRENTLY idx_jobs_queued_run_at ON jobs (run_at) WHERE status = 'queued';\nCREATE UNIQUE INDEX CONCURRENTLY users_email_live_key\n  ON users (lower(email)) WHERE deleted_at IS NULL;\n```\n\n  The query must repeat the condition as written, with a constant rather\n  than a parameter. MySQL has no partial indexes (index a generated column\n  that is NULL for the rows to skip); SQLite has them.\n- **Expression**: index what the query computes. `ON users (lower(email))`\n  serves `WHERE lower(email) = $1`, that exact expression; MySQL 8.0.13+\n  writes `INDEX ((lower(email)))`. The expression must be immutable, so\n  `date(created_at)` on a `timestamptz` is refused: filter by a range.\n- **Unique**: prefer a constraint (`UNIQUE (shop_id, sku)`), which shows in\n  the schema and can be the target of a foreign key; a unique index for\n  partial and expression rules.\n\n## 4. The other index types (Postgres)\n\n| Type | For | Example |\n|---|---|---|\n| GIN | `jsonb` containment and keys, arrays, full text, trigrams | `USING gin (tags)` |\n| GiST | Ranges and overlaps, exclusion constraints, geometry, nearest neighbour | `USING gist (during)` |\n| BRIN | Huge append-only tables whose column follows insert order | `USING brin (created_at)` |\n| HNSW (pgvector) | Vector similarity (`database-postgres`) | `USING hnsw (embedding vector_cosine_ops)` |\n| Hash | Equality only | Rarely better than B-tree |\n\n- `jsonb`: `jsonb_path_ops` is smaller and faster but serves only `@>`,\n  `@?` and `@@`; the default `jsonb_ops` also serves key existence (`?`).\n  One key compared by equality is better served by a B-tree expression:\n\n```sql\nCREATE INDEX CONCURRENTLY idx_events_payload ON events USING gin (payload jsonb_path_ops);\n-- WHERE payload @> '{\"type\": \"refund\"}'\nCREATE INDEX CONCURRENTLY idx_events_customer_id ON events ((payload ->> 'customer_id'));\n-- WHERE payload ->> 'customer_id' = $1\n```\n\n- Full text: a stored generated `tsvector` column with GIN, queried with\n  `search @@ websearch_to_tsquery('english', $1)`. Adding a stored column\n  rewrites the table, so on a big one it is a migration step of its own:\n\n```sql\nALTER TABLE articles ADD COLUMN search tsvector GENERATED ALWAYS AS\n  (to_tsvector('english', coalesce(title, '') || ' ' || coalesce(body, ''))) STORED;\nCREATE INDEX CONCURRENTLY idx_articles_search ON articles USING gin (search);\n```\n\n- Substring and fuzzy search (`ILIKE '%term%'`, similarity with `%`):\n  `CREATE EXTENSION pg_trgm;` then\n  `CREATE INDEX CONCURRENTLY idx_products_name_trgm ON products USING gin (name gin_trgm_ops);`.\n  It helps from three characters of search term up.\n- BRIN is kilobytes for billions of rows and helps only while physical order\n  follows the column (append-only events by `created_at`); on tables that\n  are updated or reordered it does nothing.\n- GIN writes are expensive; its pending list (`fastupdate`) defers them at\n  some cost to reads. Measure before adding GIN to a write-heavy table.\n\n## 5. What each index costs\n\n- Every insert writes every index. In Postgres an update that changes a\n  column in any B-tree index loses the HOT path (updating in place without\n  touching indexes) and writes every index of the table: an index on a hot\n  table's `updated_at` does that to every update.\n- Indexes compete with table data for memory; a table whose indexes are\n  bigger than its data is a smell. Vacuum, backups, restores and replication\n  carry them all.\n- Low selectivity alone is useless: `is_active` true for 95% of rows is\n  never used for `true`. If the rare value is what you query, a partial\n  index on it.\n- Update-heavy tables leave room for HOT updates with\n  `ALTER TABLE counters SET (fillfactor = 90);` (new pages; a rewrite\n  applies it to all).\n\n## 6. Foreign keys need indexes\n\nPostgres indexes the referenced key (it is unique) but not the referencing\ncolumn. Without that index a join from the parent scans the child, and each\ndelete or key update on the parent scans the child while holding locks.\nInnoDB creates one automatically. Single-column foreign keys without an\nindex whose first column matches:\n\n```sql\nSELECT c.conrelid::regclass AS table_name, c.conname, a.attname AS column_name\nFROM pg_constraint c\nJOIN pg_attribute a ON a.attrelid = c.conrelid AND a.attnum = c.conkey[1]\nWHERE c.contype = 'f' AND cardinality(c.conkey) = 1\n  AND NOT EXISTS (\n    SELECT 1 FROM pg_index i\n    WHERE i.indrelid = c.conrelid AND i.indkey[0] = c.conkey[1]\n  );\n```\n\n## 7. Missing, unused, duplicate\n\n- Missing: the top of `pg_stat_statements` by `total_exec_time`, and big\n  tables read by sequential scans:\n\n```sql\nSELECT relname, seq_scan, seq_tup_read, idx_scan, n_live_tup\nFROM pg_stat_user_tables\nWHERE n_live_tup > 100000\nORDER BY seq_tup_read DESC LIMIT 20;\n```\n\n  `auto_explain` with `auto_explain.log_min_duration = '500ms'` logs the\n  plans of slow statements. MySQL: `sys.statements_with_full_table_scans`\n  and the slow log.\n- Unused: not scanned since statistics were reset, over a window that\n  includes month-end jobs:\n\n```sql\nSELECT s.relname, s.indexrelname, s.idx_scan,\n       pg_size_pretty(pg_relation_size(s.indexrelid)) AS size\nFROM pg_stat_user_indexes s\nJOIN pg_index i ON i.indexrelid = s.indexrelid\nWHERE s.idx_scan = 0 AND NOT i.indisunique AND NOT i.indisprimary\nORDER BY pg_relation_size(s.indexrelid) DESC;\n```\n\n  Statistics are per server: check replicas before dropping, since reports\n  may use an index only there. MySQL: `sys.schema_unused_indexes`; make it\n  invisible first (`ALTER TABLE orders ALTER INDEX idx_x INVISIBLE`), drop it\n  after a quiet week.\n- Duplicates: two indexes on the same columns, or `(a)` beside `(a, b)`,\n  where the second serves both unless `(a)` is unique. MySQL:\n  `sys.schema_redundant_indexes`.\n- Bloat after heavy updates or deletes: `pgstatindex()` from `pgstattuple`\n  measures it; `REINDEX INDEX CONCURRENTLY` (Postgres 12+) rebuilds without\n  blocking.\n\n## 8. Creating and dropping on a live table\n\n- Postgres: `CREATE INDEX CONCURRENTLY` and `DROP INDEX CONCURRENTLY`,\n  outside a transaction, through the migration tool's no-transaction mode\n  (`database-migrations`). Two table scans and a wait for older\n  transactions make it slower, but writes continue. A failed build leaves an\n  `INVALID` index to drop and rebuild. `SET maintenance_work_mem = '1GB'` in\n  the session speeds up a big build.\n- MySQL: `ALTER TABLE orders ADD INDEX idx_x (col), ALGORITHM=INPLACE,\n  LOCK=NONE;` is online; on the largest tables gh-ost spares the replicas.\n- SQLite: `CREATE INDEX` blocks writers while it runs; seconds for a few\n  gigabytes, so run it at a quiet moment.\n- MongoDB builds indexes without blocking since 4.2 (`database-mongodb`).\n\n## 9. MySQL and SQLite notes\n\n- InnoDB is clustered on the primary key: rows are stored in its order and\n  every secondary index entry carries it. A wide key (a UUID string) bloats\n  every index; a random one scatters inserts (`database-mysql`).\n- MySQL prefix indexes (`INDEX (title(50))`) for long strings cannot cover a\n  query or serve `ORDER BY`; keys are limited to 3,072 bytes (768\n  `utf8mb4` characters).\n- Histograms help filters on unindexed columns:\n  `ANALYZE TABLE orders UPDATE HISTOGRAM ON status;`.\n- SQLite: confirm with `EXPLAIN QUERY PLAN`, keep statistics with\n  `PRAGMA optimize`; partial and expression indexes are supported.\n\n## Check it\n\n- `EXPLAIN (ANALYZE, BUFFERS)` of each target query before and after, on\n  realistic volumes: the new index is in the plan and time or buffers\n  dropped. If it is not in the plan, drop it.\n- The build used `CONCURRENTLY` or the engine's online form, and\n  `SELECT indexrelid::regclass FROM pg_index WHERE NOT indisvalid;` returns\n  nothing.\n- The foreign key query in section 6 lists nothing new.\n- A week after release: the new index's `idx_scan` climbs and write latency\n  on the table did not jump.\n\n## Avoid\n\nAn index per column; the range column first in a composite; indexes no plan\nuses; a boolean indexed alone; foreign keys without an index in Postgres;\n`CREATE INDEX` without `CONCURRENTLY` on a live table; GIN on `jsonb` for\nqueries that never use `@>`; dropping an unused index without checking the\nreplicas and the monthly jobs; an index on a hot table's `updated_at` with\nno query that needs it; an index judged on a table of 100 rows.\n",{"name":5,"description":7},"main","38293fe1b096e6bf3646c7344c38786ed688f464","crates\u002Fenowx-core\u002Fskills\u002Fdatabase-indexes",21,"https:\u002F\u002Fgithub.com\u002Fenowdev\u002Fenowxcli","https:\u002F\u002Fenowx.ai","https:\u002F\u002Fgithub.com\u002Fenowdev","Pretending to be a Developer","2026-10-06 02:05:35",{"source":8,"skillName":5,"commands":48,"prompt":58,"zipAvailable":59},[49,52,55],{"tool":50,"command":51},"npx","npx skills add enowdev\u002Fenowxcli --skill database-indexes",{"tool":53,"command":54},"bunx","bunx skills add enowdev\u002Fenowxcli --skill database-indexes",{"tool":56,"command":57},"pnpm","pnpm dlx skills add enowdev\u002Fenowxcli --skill database-indexes","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fenowdev\u002Fenowxcli\u002Fblob\u002Fmain\u002Fcrates\u002Fenowx-core\u002Fskills\u002Fdatabase-indexes\u002FSKILL.md",true,[],[62,73,89,102,123,142],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":33},"01M6D2HQYSQD9N7MTNDT4A7CBM","demo-skill","Project-scope demo skill for tests.","https:\u002F\u002Fgithub.com\u002Fenowdev\u002Fenowxcli\u002Fblob\u002Fmain\u002Fworkspace\u002F.agents\u002Fskills\u002Fdemo-skill\u002FSKILL.md",[],[69,70,71,72,27],"demo skill","demo","tests","project",{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":33},"01M6D2HM0GCPM0TM2HPG9HHR2R","writing","Writing words people read: the specific thing instead of claims, words to drop, sentences, interface copy (buttons, labels, errors, empty states, confirmations), page copy, notifications and emails, alt text and link text, numbers and dates, words that translate well, documentation and voice. Read before writing a page's copy, an interface's text or a document.","https:\u002F\u002Fgithub.com\u002Fenowdev\u002Fenowxcli\u002Fblob\u002Fmain\u002Fcrates\u002Fenowx-core\u002Fskills\u002Fwriting\u002FSKILL.md",[],[75,26,80,81,82,83,27,84,85,86,87,88],"emails","empty","drop","document","page","voice","notifications","documentation","translate",{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":33},"01M6D2HG07YS49NM196Q0R3AZ8","ui","Designing or restyling an interface: direction, layout, type, colour, icons, components, states, responsive behaviour. Read before building a page, a screen or a set of components.","https:\u002F\u002Fgithub.com\u002Fenowdev\u002Fenowxcli\u002Fblob\u002Fmain\u002Fcrates\u002Fenowx-core\u002Fskills\u002Fui\u002FSKILL.md",[],[91,96,97,98,99,84,100,27,101],"icons","components","SET","responsive","layout","before building",{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":33},"01M6D2HB59HZHWG1RYZDV4SJ91","ui-themes","Light and dark themes, and colour that holds in both: tokens with a value per theme, and what each kind of content needs to stay visible (icons, SVG drawings and line art, logos, photos, screenshots, charts, code, maps, borders, shadows, focus, form controls), switching without a flash, and checking both. Read before building a second theme or a theme toggle, and before any drawing, logo or chart on a page that has two themes.","https:\u002F\u002Fgithub.com\u002Fenowdev\u002Fenowxcli\u002Fblob\u002Fmain\u002Fcrates\u002Fenowx-core\u002Fskills\u002Fui-themes\u002FSKILL.md",[],[91,109,110,111,112,113,114,115,116,27,101,117,84,118,119,120,96,121,122],"ui themes","switching","photos","tokens","drawing","focus","maps","Art","flash","code","Charts","content","screenshots","logo",{"skillNo":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":127,"categories":128,"keywords":129,"publishedAt":33},"01M6D2H5R5KRAE524C8QX0T7Q0","ui-structure","Structure before styling: the blueprint written before any interface code (the screen's job, the regions its kind of page needs, their order and why, the layout skeleton in numbers, the components and their states), the anatomy and order of a homepage, a dashboard, a list, a detail page, settings, a form, sign-in, pricing, docs, an article and a checkout, and how to turn the blueprint into code (tokens, layout primitives, components, sections, page). Read first, before building or rebuilding any page or screen.","https:\u002F\u002Fgithub.com\u002Fenowdev\u002Fenowxcli\u002Fblob\u002Fmain\u002Fcrates\u002Fenowx-core\u002Fskills\u002Fui-structure\u002FSKILL.md",[],[130,91,131,97,132,133,118,134,135,136,100,112,137,138,139,27,101,84,140,141],"structure","ui structure","pricing","dashboard","Blueprint","article","anatomy","styling","primitives","list","why","how",{"skillNo":143,"name":144,"nameZh":6,"description":145,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":146,"categories":147,"keywords":148,"publishedAt":33},"01M6D2H0ZZBJG77MBGPZHA6MWD","ui-stack-vue","Building interfaces in Vue 3 and Nuxt: project layout, script setup with typed defineProps, defineEmits and defineModel, attribute fallthrough, slots and scoped slots, template refs, ref, reactive and computed, watch versus watchEffect, composables and VueUse, provide and inject, Pinia, keyed v-for, transitions, Nuxt 4 (app directory, pages, layouts, useFetch and useAsyncData keys, $fetch in handlers, server routes, runtime config, useSeoMeta, NuxtImg, middleware), VeeValidate forms, Reka UI and Nuxt UI, testing, vue-tsc, and the traps. Read when the project uses Vue or Nuxt.","https:\u002F\u002Fgithub.com\u002Fenowdev\u002Fenowxcli\u002Fblob\u002Fmain\u002Fcrates\u002Fenowx-core\u002Fskills\u002Fui-stack-vue\u002FSKILL.md",[],[91,149,150,151,152,153,154,155,100,72,156,157,27,158,159,160,161,162,163,164],"vue","stack","ui stack vue","forms","pages","watch","runtime","transitions","fetch","pinia","nuxt","template","server","config","directory","testing"]