- Home
- Skills
- Data & Databases
- Slow Query Report: Why Your SQL Is Slow, from Its Plan
More screenshots
Works with the AI Agents you already use
Slow Query Report: Why Your SQL Is Slow, from Its Plan
- `query-report.html`: the same as one printable page, with plan excerpts beside the points they support.
$6
Slow Query Report: Why Your SQL Is Slow, from Its Plan
Example session with this skill installed
The customer orders screen takes over a second. Here is the query and the EXPLAIN (ANALYZE, BUFFERS) output from PostgreSQL 16, and our table definitions.
- Read your context and instructions
- Compiled the slow query report
D2. The email lookup reads every customer
- Basis: plan, query
- Evidence:
plan.txt:21,plan.txt:22,plan.txt:23,query.sql:11
-> Parallel Seq Scan on customers c (cost=0.00..28646.54 rows=2604 width=8) (actual time=161.884..238.517 rows=0 loops=3)
Filter: (lower((email)::text) = '<redacted>'::text)
Rows Removed by Filter: 416666
customers is read in full and the filter throws away 416,666 rows in each process, about 1.25 million in all, to keep one. The query compares lower(c.email) (query.sql:11), while the only index on the column is the unique constraint on plain email (schema.sql:6). An index on email cannot serve a condition on lower(email). This step takes about 239 ms (21 %).
Suggested index
CREATE INDEX CONCURRENTLY customers_lower_email_idx
ON customers (lower(email));
CREATE INDEX CONCURRENTLY orders_customer_id_created_at_idx
ON orders (customer_id, created_at DESC, id DESC);
$ python3 scripts/report_check.py query/query-report.md --plan query/plan.json --sql query/sql.json
summary: 0 FIX, 0 ADVICE in query-report.md (5 diagnosis points: 4 plan, 1 query, 1 schema, 1 heuristic; 2 suggested index(es); 7 open questions). It checks the evidence and the safe form of the suggestions; it runs nothing and cannot tell whether the query will be faster: confirm on a copy.
Connects securely to your tools. The creator never sees your data.
About this skill
English
For developers with a slow PostgreSQL or MySQL query and its execution plan in hand.
Paste the query and its plan into your agent. You get back a report that says why it is slow, with every point citing its line in the plan or the query, plus a rewrite, a suggested index with its costs, and how to confirm the result on a copy.
What you get each run
query-report.md: the engine and version, what the query should return, the diagnosis, the rewrite and what could change in its results, the suggested index, when the index may not help, how to confirm, and questions for the team.query-report.html: the same as one printable page, with plan excerpts beside the points they support.plan.jsonandsql.json: what the readers found in the plan and the query, every fact with its line.
Read from what you paste
Bundled Python scripts (standard library, read-only, no network calls) read PostgreSQL EXPLAIN (ANALYZE, BUFFERS) as text or JSON and MySQL 8 EXPLAIN ANALYZE (tree) or EXPLAIN FORMAT=JSON, plus your CREATE TABLE and CREATE INDEX statements if you give them. They find full scans, rows thrown away by filters, row estimates that were far off, sorts that spill to disk, hash batches, repeated loops and the steps that take the most time. The query reader marks functions on filtered columns, leading-wildcard LIKE, OR across columns, NOT IN with a subquery and large OFFSET as candidates.
It never touches your database
Nothing connects to a database. The report is written from what you pasted, and every change it suggests is for a copy or staging database first.
Suggestions with their costs
The rewrite says what could change in its results: NULLs, duplicates, order. The suggested index comes with its costs said plainly: extra writes, disk size, build time and locking (CONCURRENTLY on PostgreSQL, the online options on MySQL). The confirm steps run the new plan in the same form and check that both queries return the same rows.
Checked, not just written
A checker confirms every cited plan and query line exists, index columns exist in the schema you gave, the index does not repeat an existing one, the confirm section checks that results are equal, and no data-changing statement appears. The agent fixes and checks again until no FIX is left.
Honest about its limits
The checker cannot tell whether the query will be faster: only the new plan on a copy shows that. Heuristic points are labelled as such. The engine and version are asked for, because plan formats differ.
Arabic
The report can be written in Arabic with a right-to-left page; SQL, plan excerpts and names stay as they are.
In the download: SKILL.md, the scripts, references (the report format, the plan formats each reader accepts, the query reader's limits, index costs and how to confirm), and complete examples so you can see the output before you buy: a customer orders screen on PostgreSQL 16 in English, and a sales report query on MySQL 8 in English and Arabic.
بالعربي
للمبرمجين الذين بين أيديهم استعلام PostgreSQL أو MySQL بطيء وخطة تنفيذه.
الصق الاستعلام وخطته لوكيلك. تستلم تقريرًا يقول لماذا هو بطيء، وكل نقطة تذكر سطرها في الخطة أو في الاستعلام، مع إعادة كتابة، وفهرس مقترح بتكاليفه، وطريقة التأكد من النتيجة على نسخة.
ماذا تستلم في كل مرة
- ملف
query-report.md: المحرك والإصدار، وما يجب أن يعيده الاستعلام، والتشخيص، وإعادة الكتابة وما قد يتغير في نتائجها، والفهرس المقترح، ومتى قد لا يفيد، وكيف تتأكد، وأسئلة للفريق. - صفحة
query-report.html: الشيء نفسه كصفحة واحدة قابلة للطباعة، ومقتطفات الخطة بجانب النقاط التي تسندها. - ملفا
plan.jsonوsql.json: ما وجده القارئان في الخطة والاستعلام، وكل معلومة مع سطرها.
من الذي تلصقه أنت
سكربتات بايثون مرفقة (تقرأ فقط، بلا اتصال بالشبكة) تقرأ خطط PostgreSQL من EXPLAIN (ANALYZE, BUFFERS) نصًا أو JSON، وخطط MySQL 8 من EXPLAIN ANALYZE أو EXPLAIN FORMAT=JSON، وتعريفات الجداول والفهارس إن أعطيتها. تجد المسح الكامل، والصفوف التي يرميها الفلتر، والتقديرات البعيدة عن الواقع، والفرز الذي ينزل إلى القرص، والحلقات المتكررة، والخطوات الأكثر استهلاكًا للوقت.
لا يلمس قاعدة بياناتك
لا شيء يتصل بقاعدة البيانات. التقرير مكتوب مما لصقته، وكل تغيير مقترح يُجرَّب على نسخة أو قاعدة تجريبية أولًا.
اقتراحات مع تكاليفها
إعادة الكتابة تذكر ما قد يتغير في النتائج: القيم الفارغة، والتكرار، والترتيب. والفهرس المقترح معه تكاليفه بوضوح: كتابات إضافية، وحجم على القرص، ووقت البناء والقفل. وخطوات التأكد تشغّل الخطة الجديدة بالشكل نفسه وتتأكد أن الاستعلامين يعيدان الصفوف نفسها.
مدقَّق، لا مكتوب فقط
أداة فحص تتأكد أن كل سطر مذكور من الخطة والاستعلام موجود، وأعمدة الفهرس موجودة في الجداول المعطاة، والفهرس لا يكرر فهرسًا موجودًا، وقسم التأكد يقارن النتائج، ولا توجد جملة تغيّر البيانات. يصلح الوكيل ويعيد الفحص حتى لا يبقى أي FIX.
صادق في حدوده
الأداة لا تعرف هل سيصير الاستعلام أسرع: الخطة الجديدة على نسخة هي التي تبيّن ذلك. والنقاط المبنية على قراءة عامة مكتوب أنها كذلك.
العربية
يُكتب التقرير بالعربي في صفحة من اليمين إلى اليسار، ويبقى SQL ومقتطفات الخطة والأسماء كما هي.
داخل الملف: ملف SKILL.md، والسكربتات، والمراجع، وأمثلة كاملة لترى النتيجة قبل الشراء: شاشة طلبات عملاء على PostgreSQL 16 بالإنجليزي، واستعلام تقرير مبيعات على MySQL 8 بالإنجليزي والعربي.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Data & Databases.
Reads PostgreSQL 12+ EXPLAIN (ANALYZE, BUFFERS) as text or JSON and MySQL 8 EXPLAIN ANALYZE (tree) or EXPLAIN FORMAT=JSON; other plan forms are refused with a message naming the accepted ones. Plain EXPLAIN without ANALYZE gives estimates only, and the report says so. The query reader is a careful text reader, not a full SQL parser, and marks its patterns as candidates. It never connects to a database, so it cannot tell whether the query will be faster: only the new plan on a copy shows that. Index costs depend on your table and write load, which the report asks about. query-report.html loads its fonts from Google Fonts when online and falls back to system fonts offline. لا يتصل بقاعدة البيانات، والخطة الجديدة على نسخة هي الحكم.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 3 days ago
- Software
Python
Permissions
Reads the query, plan and table definitions you paste (saved as files in a query folder) and, if you point to them, migration files in your repository. Writes plan.json, sql.json, query-report.md and query-report.html in that folder, and runs its local Python scripts (plan_read.py, sql_read.py, report_check.py, make_page.py). The scripts never connect to a database, run nothing and make no network calls. يقرأ ما تلصقه ويكتب ملفات التقرير فقط، ولا يتصل بقاعدة البيانات.