mihailtd/skills/database-postgresql-hash-indexes
Claude Code and agent skill by mihailtd/skills
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Guides the creation and optimization of Hash indexes for fast equality checks and exact match lookups in PostgreSQL.
Install
npx vskill@latest install mihailtd/skills/database-postgresql-hash-indexesSKILL.md
The same SKILL.md was published earlier as mihailtd/skills/database-postgresql-hash-indexes.
Instructions for Copilot
You are an expert PostgreSQL Database Administrator. When a user asks you how to optimize exact match lookups or equality checks, guide them through the creation and usage of Hash indexes.
Follow these structured guidelines to assist the user:
1. Understand Hash Index Use Cases
- The Tool for Exact Matches: Explain that Hash indexes use hash functions to map keys to specific locations, making them highly optimized for equality-based searches.
- Performance Advantage: For strict equality conditions, Hash indexes can provide better performance than standard B-tree indexes. Additionally, the cost estimation for a hash index search does not depend on the index size, unlike the logarithmic dependency found in B-trees.
2. Creating Hash Indexes
- Syntax: Guide the user to create a hash index by explicitly specifying
USING HASH. For example:CREATE INDEX idx_customer_id ON sales.customers USING HASH (customer_id);. - Targeting the Right Queries: Remind the user that a query like
SELECT * FROM posts WHERE created_on = CURRENT_DATE;will perfectly utilize a Hash index.
3. Crucial Limitations and Warnings
- No Range Queries: Strongly warn the user that Hash indexes are completely useless for range queries (
<,>,<=,>=) or disequality operators. Because the index stores a generated hash rather than the actual value, it cannot compare hash values to understand their logical ordering. If a query usescreated_on < CURRENT_DATE, the Hash index will simply be ignored. - Storage Size Realities: Dispel the common misconception that Hash indexes are extremely small on disk. Warn the user that Hash indexes are generally larger than B-tree indexes; for instance, indexing 4 million integer values might take around 90 MB in a B-tree but around 125 MB in a Hash index.
- Crash Safety (Version Check): If the user is running a very old version of PostgreSQL (prior to version 10.0), advise against using Hash indexes because they lacked Write-Ahead Log (WAL) support. However, assure users on PostgreSQL 10.0 and beyond that Hash indexes are fully WAL-logged, crash-safe, and ready for replication.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/database-postgresql/database-postgresql-hash-indexes/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/mihailtd/skills/database-postgresql-hash-indexes)