queryset-optimizer

Detect N+1 query patterns and missing eager loading in Django ORM.

5|Updated Feb 21, 2026
One-click install
npx skills add https://github.com/ragnarok22/agent-skills --skill queryset-optimizer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: queryset-optimizer
Source: https://github.com/ragnarok22/agent-skills/tree/main/skills/queryset-optimizer
Command: npx skills add https://github.com/ragnarok22/agent-skills --skill queryset-optimizer

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and agents (resource) components.

What problem does it solve?

This Skill helps identify and fix performance bottlenecks in Django's Object-Relational Mapper (ORM), specifically addressing issues like N+1 query patterns and inefficient database interactions.

Core Features & Use Cases

  • N+1 Detection: Identifies common "N+1" query problems where a loop triggers excessive database calls.
  • Eager Loading Optimization: Detects missing select_related and prefetch_related calls for efficient data fetching.
  • Index Gap Analysis: Flags potential missing database indexes that slow down queries.
  • Use Case: Optimize a slow-loading Django admin page or API endpoint by identifying and resolving inefficient database queries.

Quick Start

Use the queryset-optimizer skill to audit the Django ORM queries for the 'users' endpoint.

Frequently Asked Questions about queryset-optimizer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix N+1 query problems in Django ORM?

Resolve N+1 query patterns in Django ORM by detecting loop-triggered database calls and applying missing eager loading functions like select_related and prefetch_related for efficient data fetching.

How do I find missing select_related and prefetch_related calls in Django?

Find missing select_related and prefetch_related calls by auditing your Django backend endpoints to receive a detailed report with a scoring system and prioritized remediation actions for inefficient queries.

What is the best way to optimize a slow Django admin page or API endpoint?

Optimize a slow Django admin page or API endpoint by identifying inefficient database interactions, resolving N+1 query patterns, and flagging potential missing database indexes that slow down queries.

How do I detect missing database indexes slowing down Django queries?

Detect missing database indexes slowing down Django queries through an index gap analysis that flags potential missing indexes and provides prioritized remediation actions for those inefficiencies.

Does queryset optimization work for any Django backend endpoint?

Queryset optimization works for any Django backend development context by auditing ORM queries for specific endpoints, such as the users endpoint, to improve database interaction efficiency.