Chuyển đến nội dung
Skillpedia
Lập trình chung48k · #5845

sql-optimization-patterns

Skill này làm gì

Công cụ này giúp tìm và sửa các lỗi khiến truy vấn cơ sở dữ liệu chạy chậm. Nó phân tích cách cơ sở dữ liệu thực thi lệnh của bạn và gợi ý cải thiện, như thêm index hoặc viết lại truy vấn, để chạy nhanh hơn.

Khi nào nên dùng

  • ✓Khi một truy vấn cơ sở dữ liệu phản hồi quá chậm.
  • ✓Khi thiết kế hoặc điều chỉnh cấu trúc cơ sở dữ liệu để tăng hiệu năng.
  • ✓Khi bạn muốn hiểu vì sao cơ sở dữ liệu bị quá tải và cách giảm tải đó.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/sql-optimization-patterns/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/sql-optimization-patterns/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Truy vấn SQL lấy danh sách người dùng của tôi rất chậm, bạn có thể giúp tôi tối ưu nó không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ phân tích “execution plan” của truy vấn, tức là cách cơ sở dữ liệu quyết định thực thi lệnh. Dựa trên đó, nó đề xuất thay đổi như thêm index hoặc viết lại truy vấn để hiệu quả hơn.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

SQL Optimization Patterns

Diagnose slow SQL with query plans, preserve query results, and verify indexing or query changes against representative data.

Use this skill when

  • Debugging slow-running queries
  • Designing performant database schemas
  • Optimizing application response times
  • Reducing database load and costs
  • Improving scalability for growing datasets
  • Analyzing EXPLAIN query plans
  • Implementing efficient indexes
  • Resolving N+1 query problems

Do not use this skill when

  • The task is unrelated to sql optimization patterns
  • You need a different domain or tool outside this scope

Instructions

  • Confirm database engine/version, query parameters, expected rows, data distribution and the permitted environment. Start read-only; obtain authorization before DDL, data changes, configuration changes or maintenance.
  • Compare result sets before comparing performance. EXPLAIN ANALYZE executes the statement: use approved representative data, account for functions and triggers, and do not assume a transaction rollback undoes every side effect.
  • Record the observed plan, timing conditions and correctness checks. Indexes and query rewrites are hypotheses, not universal speed improvements.
  • If detailed examples are required, open resources/implementation-playbook.md.

Resources

  • resources/implementation-playbook.md for detailed patterns and examples.

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.

Worked example

The playbook includes an executable SQLite batch-loading example with bound values and an empty-input case. The repository test exercises it alongside pagination ties and aggregation equivalence. SQLite correctness checks do not establish PostgreSQL performance or production safety.

Câu hỏi thường gặp

“Execution plan” là gì?

Đó là con đường mà cơ sở dữ liệu chọn để tìm và trả về dữ liệu bạn yêu cầu. Phân tích nó giúp thấy chỗ nào đang gây chậm.

“Index” là gì?

Index giống như mục lục của một cuốn sách. Nó giúp cơ sở dữ liệu tìm thông tin cụ thể nhanh hơn nhiều, mà không phải đọc toàn bộ dữ liệu.

Công cụ có tự thay đổi cơ sở dữ liệu của tôi không?

Không trực tiếp. Công cụ chỉ đề xuất thay đổi và xin phép bạn trước khi sửa bất kỳ thứ gì, bắt đầu từ các phân tích chỉ đọc.

Chi tiết

Mô tả gốc của tác giả

Diagnose slow SQL with query plans, preserve query results, and verify indexing or query changes against representative data.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#5845
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự