smithery/ambersun1234

database skill

describe how to write database related code in the codebase, use when you need to add or modify database related code or user ask to optimize to the codebase

Installation

$ npx skills add smithery/ambersun1234 --skill database-skill

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery/ambersun1234.

npx skills add smithery/ambersun1234

Browse all from smithery/ambersun1234

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,091 B
  • docs SUMMARY.md 179 B

History

  1. First recorded snapshot · 0 installs

SKILL.md

database best practices

the document outlines the best practices for writing database related code in the codebase.

when to use this skill

when you need to add or modify database related code or user ask to optimize the database related code to the codebase

best practices

  • you should always try to select only necessary data from the database, don't select all the data from the database
  • if you encounter performance issue, you should check the table definition, index, query plan ... etc. to optimize the query
  • you should always try to set up an index for the column that has a high cardinality, for example, user id, product id ... etc.
  • you should always try to set up a composite index for the column that is frequently used together, for example, user id and product id ... etc.
  • you should always try to set up a partial index for the column that is frequently used together, for example, user id and first_bought(bool) ... etc.
  • you should always try to use transaction whenever possible to ensure data consistency, and rollback the transaction if the operation failed
  • if transaction is not applicable, you should deploy saga pattern to ensure data consistency and proper compensate mechanism
  • you should try to select multiple rows at once whenever possible to prevent N+1 query issue
  • you should avoid full table scan when query the data, like where name like '%test%' ... etc.(however where name like 'test%' is acceptable because it's a prefix scan)
  • for any fast query, you should always try to use database addons whenever possible, like postgresql gin and gist index, custom operator and query function ... etc.
  • if database join is not applicable, you should use multiple queries to get the data and merge it in the application layer
  • for pagination query, always use cursor based pagination whenever possible, don't use offset based pagination