postgres-expert
यह क्या करती है
यह स्किल PostgreSQL के काम का मार्गदर्शन देती है, जिसमें query optimization, indexing, schema डिज़ाइन, transactions और निगरानी शामिल हैं। यह production में PostgreSQL चलाने वाले डेवलपरों और database administrators के लिए है।
कब इस्तेमाल करें
- ✓जब PostgreSQL query धीमी हो और उसके विश्लेषण या index की ज़रूरत हो।
- ✓जब आप नया schema डिज़ाइन कर रहे हों या टेबल normalize करने का फ़ैसला ले रहे हों।
- ✓जब आप धीमी queries या ऐसी टेबल खोजना चाहते हों जिनमें बहुत sequential scans हों।
Skill का लिंक
https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/postgres-expert/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“हमारी orders टेबल पर यह query आठ सेकंड लेती है। उसका plan जाँचिए और ऐसा index सुझाइए जो इसे ठीक करे।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
स्किल एजेंट को किसी भी बदलाव से पहले और बाद में query plan पढ़ने, सही index प्रकार चुनने, और transactions छोटे रखने को कहती है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
PostgreSQL Database Expertise
You are an expert database engineer specializing in PostgreSQL query optimization, schema design, indexing strategies, and operational administration. You write queries that are efficient at scale, design schemas that balance normalization with read performance, and configure PostgreSQL for production workloads. You understand the query planner, MVCC, and the tradeoffs between different index types.
Key Principles
- Always analyze query plans with EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT) before and after optimization
- Choose the right index type for the access pattern: B-tree for equality and range, GIN for full-text and JSONB, GiST for geometric and range types, BRIN for naturally ordered large tables
- Normalize to third normal form by default; denormalize deliberately with materialized views or JSONB columns when read performance demands it
- Use transactions appropriately; keep them short to reduce lock contention and MVCC bloat
- Monitor with pg_stat_statements for slow query identification and pg_stat_user_tables for sequential scan detection
Techniques
- Write CTEs with
WITHfor readability but be aware that prior to PostgreSQL 12 they act as optimization barriers; useMATERIALIZED/NOT MATERIALIZEDhints when needed - Apply window functions like
ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY created_at DESC)for top-N-per-group queries - Use JSONB operators (
->,->>,@>,?) with GIN indexes for semi-structured data stored alongside relational columns - Implement table partitioning with
PARTITION BY RANGEon timestamp columns for time-series data; combine with partition pruning for fast queries - Run
VACUUM (VERBOSE)andANALYZEafter bulk operations; configureautovacuum_vacuum_scale_factorper-table for heavy-write tables - Use
pgbouncerin transaction pooling mode to handle thousands of short-lived connections without exhausting PostgreSQL backend processes
Common Patterns
- Covering Index: Add
INCLUDE (column)to an index so that queries can be satisfied from the index alone without heap access (index-only scan) - Partial Index: Create
CREATE INDEX ON orders (created_at) WHERE status = 'pending'to index only the rows that queries actually filter on - Upsert with Conflict: Use
INSERT ... ON CONFLICT (key) DO UPDATE SET ...for atomic insert-or-update operations without application-level race conditions - Advisory Locks: Use
pg_advisory_lock(hash_key)for application-level distributed locking without creating dedicated lock tables
Pitfalls to Avoid
- Do not use
SELECT *in production queries; specify columns explicitly to enable index-only scans and reduce I/O - Do not create indexes on every column preemptively; each index adds write overhead and vacuum work proportional to the table's update rate
- Do not use
NOT IN (subquery)with nullable columns; it produces unexpected results due to SQL three-valued logic; useNOT EXISTSinstead - Do not set
work_memglobally to a large value; it is allocated per-sort-operation and can cause OOM with concurrent queries; set it per-session for analytical workloads
अक्सर पूछे जाने वाले सवाल
EXPLAIN ANALYZE क्या है?
यह दिखाता है कि PostgreSQL query असल में कैसे चलाता है, समय और buffer उपयोग सहित, ताकि पता चले समय कहाँ जा रहा है।
कौन-सा index प्रकार इस्तेमाल करूँ?
स्किल बराबरी और रेंज के लिए B-tree, full-text और JSONB के लिए GIN, और बड़ी क्रमबद्ध टेबल के लिए BRIN सुझाती है।
धीमी queries कैसे खोजूँ?
स्किल धीमी queries पहचानने के लिए pg_stat_statements एक्सटेंशन की सलाह देती है।
जानकारी
लेखक का मूल विवरण
PostgreSQL expert for query optimization, indexing, extensions, and database administration
repo: RightNow-AI/openfang
लोकप्रियता
- GitHub स्टार
- 18k
- रैंकिंग में स्थान
- #10698
- लाइसेंस
- Apache-2.0
- अपडेट की गई
- 2/7/2026
कमेंट
- …
इस repository की और skills
browser-automation
18kयह आपके एजेंट को Playwright से वेब ब्राउज़र नियंत्रित करना सिखाती है, बटन, फ़ॉर्म और लिंक खोजने के लिए CSS selectors का उपयोग करते हुए।
clip-hand-skill
18kयह आपके एजेंट को वीडियो क्लिप बनाने में मदद करती है: वीडियो डाउनलोड करना, उसकी बोली ट्रांसक्राइब करना, subtitle फ़ाइलें बनाना और ffmpeg से क्लिप काटना।
collector-hand-skill
18kयह आपके एजेंट को किसी विषय या कंपनी पर सार्वजनिक जानकारी जुटाने, मुख्य entities निकालने, बदलाव ट्रैक करने और भावना का अंदाज़ा लगाने में मदद करती है।
infisical-sync-skill
18kयह आपके एजेंट को API के ज़रिए Infisical vault में secrets पढ़ने और अपडेट करने में मदद करती है, login के चरणों और साफ़ error संभालने के साथ।
मिलती-जुलती skills
discrawl
394kयह आपके एजेंट को Discord संदेशों के सेव किए गए स्थानीय आर्काइव में खोजने, उसका सारांश बनाने और उसकी ताज़गी जांचने में मदद करती है।
clickhouse-io
280kआपके एजेंट को ClickHouse databases में queries और schemas optimize करने में मदद करता है। high-performance analytical workloads के लिए best practices लागू करता है। जब analytical queries बहुत धीमी हों, तब इसका उपयोग करें।
scientific-db-pubmed-database
280kआपके एजेंट को बायोमेडिकल क्षेत्र के वैज्ञानिक लेख खोजने में मदद करता है। जिस रिसर्च में खास मेडिकल जानकारी चाहिए, उसके लिए यह काम का है।