postgresql
Skill15 starsChanged 42 days agoMITView on GitHub
Expert PostgreSQL assistance covering advanced SQL, JSONB, indexing (B-Tree, GIN, BRIN), query optimization with EXPLAIN ANALYZE, and replication. Use when designing robust relational schemas or tuning performance.
21 other projects use a version of this.
Adopted by
Most recently taken up by
- iliaal/ai-skillstheir own version, first seen Nov 7, 2026
- speakeasy-api/gramtheir own version, first seen Nov 6, 2026
- lawless-m/claude-skillstheir own version, first seen Nov 6, 2026
- malinskibeniamin/skillstheir own version, first seen Oct 17, 2026
- 1tomany/agent-skillstheir own version, first seen Oct 15, 2026
- xfstudio/skillstheir own version, first seen Oct 13, 2026
Other versions21 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 21
- speakeasy-api/gram★ 277same name
- kid-sid/claude-spellbook★ 190same name
- iliaal/ai-skills★ 45same name
- kumaran-is/claude-code-onboarding★ 35same name
- xfstudio/skills★ 9same name
- lawless-m/claude-skills★ 6same name
- malinskibeniamin/skills★ 4same name
- stonegiantstudio/skills★ 3same name
- ai4brands-design/claude-skills★ 2same name
- bcastelino/agent-skills-kit★ 2same name
11 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository350 other files it gives its agents.
- airflowSkill
- catboostSkill
- claudeSkill
- comfyuiSkill
- cursor-aiSkill
- dalleSkill
- daskSkill
- dbtSkill
- deepseekSkill
- fastaiSkill
- geminiSkill
- github-copilotSkill
- huggingfaceSkill
- jaxSkill
- jupyterSkill
- kerasSkill
- langchainSkill
- lightgbmSkill
- llamaindexSkill
- llamaSkill
- matplotlibSkill
- midjourneySkill
- mistralSkill
- mlflowSkill
- nltkSkill
- numpySkill
- ollamaSkill
- openai-gptSkill
- opencvSkill
- pandasSkill
- perplexitySkill
- plotlySkill
- polarsSkill
- pytorchSkill
- raySkill
- scikit-learnSkill
- seabornSkill
- spacySkill
- sparkSkill
- stable-diffusionSkill
- tensorflowSkill
- vaexSkill
- weights-biasesSkill
- whisperSkill
- xgboostSkill
- api-gatewaySkill
- clean-architectureSkill
- cqrsSkill
- domain-driven-designSkill
- event-drivenSkill
- event-sourcingSkill
- graphqlSkill
- grpcSkill
- hexagonalSkill
- microservicesSkill
- modular-monolithSkill
- monolithSkill
- rest-apiSkill
- sagaSkill
- serverlessSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
7 rules. 0 are common, 2 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 20 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 95
Use PostgreSQL JSONB data type with GIN index:
- Distinctive: line 116
Use Connection Poolers (PgBouncer): Prevent process-per-connection exhaustion by running PgBouncer in transaction pooling mode.
- Very specific: line 117
Use TIMESTAMPTZ for Date Columns: Always store timestamps with timezone information (TIMESTAMPTZ), never bare TIMESTAMP.
- Very specific: line 118
Create Partial and Expression Indexes: Index only active rows (WHERE deleted_at IS NULL) to keep index sizes compact.
- Very specific: line 119
Run EXPLAIN (ANALYZE, BUFFERS): Analyze exact buffer hits and query execution plans before deploying new queries.
- Very specific: line 123
Use SERIAL for new tables: Use standard SQL identity columns (GENERATED ALWAYS AS IDENTITY) or UUIDv7.
- Distinctive: line 125
Write long-running transactions: Long open transactions block vacuuming and cause severe table bloat.
“Common” is measured: kept by at least 6 in 10 of the 20 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
PostgreSQL
PostgreSQL (Postgres) is a powerful, open-source object-relational database system. It is known for its reliability, feature robustness (JSONB, GIS, Full Text Search), and performance.
When to Use
- The Default Advanced Relational Database: The standard, most versatile open-source relational database for modern software engineering.
- Semi-Structured Document Storage (JSONB): Storing, indexing, and querying JSON documents with GIN indexes and JSONPath expressions.
- AI & Vector Embeddings (pgvector): Storing high-dimensional vector embeddings and executing cosine/L2 semantic similarity search.
- Geospatial Applications (PostGIS): Analyzing spatial geometries, geographic boundaries, and GPS coordinates with industry-standard PostGIS.
Quick Start
-- JSONB column usage
CREATE TABLE events (
id SERIAL PRIMARY KEY,
data JSONB
);
INSERT INTO events (data) VALUES ('{"type": "login", "user": "alice"}');
-- Query JSON directly (indexing supported)
SELECT * FROM events WHERE data->>'user' = 'alice';Core Concepts
Advanced JSONB & Generalized Inverted Indexes (GIN)
JSONB stores binary decomposed JSON with full indexing support:
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
profile JSONB NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- Create GIN Index over entire JSONB structure
CREATE INDEX idx_users_profile ON users USING GIN (profile);
-- Fast sub-millisecond containment search
SELECT * FROM users
WHERE profile @> '{"role": "admin", "settings": {"notifications": true}}';pgvector Semantic Similarity Search
Integrates AI vector embeddings directly alongside relational tables:
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE document_embeddings (
id BIGSERIAL PRIMARY KEY,
content TEXT,
embedding vector(1536) -- OpenAI embedding dimension
);
-- Create HNSW index for sub-5ms approximate nearest neighbor search
CREATE INDEX idx_embeddings_hnsw ON document_embeddings
USING hnsw (embedding vector_cosine_ops);
-- Find top 5 most semantically similar documents
SELECT id, content, 1 - (embedding <=> '[0.012, -0.045, ...]') AS similarity
FROM document_embeddings
ORDER BY embedding <=> '[0.012, -0.045, ...]'
LIMIT 5;Multi-Version Concurrency Control (MVCC) & VACUUM
PostgreSQL retains old row versions on update/delete; the autovacuum daemon reclaims dead tuples:
-- Inspect bloat and dead tuples
SELECT relname, n_live_tup, n_dead_tup, last_autovacuum
FROM pg_stat_user_tables
WHERE relname = 'users';Common Patterns
JSONB Ingestion with GIN Indexing for Fast Document Queries
Problem: Relational normalization adds too much overhead for variable schema payloads, but standard text search is slow.
Solution:
Use PostgreSQL JSONB data type with GIN index:
CREATE TABLE audit_events (
id BIGSERIAL PRIMARY KEY,
event_time TIMESTAMPTZ NOT NULL DEFAULT NOW(),
metadata JSONB NOT NULL
);
-- GIN index supports fast top-level and nested key existence queries
CREATE INDEX idx_audit_metadata ON audit_events USING GIN (metadata jsonb_path_ops);
-- Fast indexed query matching nested key-value
SELECT * FROM audit_events
WHERE metadata @> '{"action": "LOGIN", "status": "FAILED"}';Best Practices
Do:
- Use Connection Poolers (PgBouncer): Prevent process-per-connection exhaustion by running PgBouncer in transaction pooling mode.
- Use
TIMESTAMPTZfor Date Columns: Always store timestamps with timezone information (TIMESTAMPTZ), never bareTIMESTAMP. - Create Partial and Expression Indexes: Index only active rows (
WHERE deleted_at IS NULL) to keep index sizes compact. - Run
EXPLAIN (ANALYZE, BUFFERS): Analyze exact buffer hits and query execution plans before deploying new queries.
Don't:
- Use
SERIALfor new tables: Use standard SQL identity columns (GENERATED ALWAYS AS IDENTITY) orUUIDv7. - Disable Autovacuum: Disabling autovacuum causes catastrophic table bloat and transaction ID wraparound emergencies.
- Write long-running transactions: Long open transactions block vacuuming and cause severe table bloat.
Troubleshooting
| Error | Cause | Solution |
FATAL: remaining connection slots are reserved for non-replication superuser | Max connections exceeded by application instances. | Deploy PgBouncer connection pooler and tune max_connections. |
Seq Scan on large table in EXPLAIN ANALYZE | Planner chose sequential scan due to stale statistics or missing index. | Run ANALYZE tablename; or create index matching query predicates. |
deadlock detected (ERROR: 40P01) | Concurrent transactions acquired locks in opposing order. | Standardize lock acquisition order across transactions and keep transactions small. |
References
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

