ワンクリックで
database-query-optimizer
Use when optimizing SQLAlchemy queries or addressing N+1 problems
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use when optimizing SQLAlchemy queries or addressing N+1 problems
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | database-query-optimizer |
| description | Use when optimizing SQLAlchemy queries or addressing N+1 problems |
from sqlalchemy.orm import joinedload, selectinload
# joinedload = single JOIN query (good for to-one)
skills = db.query(Skill).options(joinedload(Skill.category_rel)).all()
# selectinload = separate IN query (good for to-many)
skills = db.query(Skill).options(selectinload(Skill.divisions)).all()
CREATE INDEX idx_skills_category ON skills(category);
CREATE INDEX idx_skills_status ON skills(status);
CREATE INDEX idx_skills_trending ON skills(trending_score DESC);
CREATE INDEX idx_installs_skill_user ON installs(skill_id, user_id);
CREATE INDEX idx_favorites_user ON favorites(user_id);
CREATE INDEX idx_audit_log_event ON audit_log(event_type, created_at);
Counters on skills table (install_count, etc.) avoid expensive COUNT queries. Trade-off: must update on every social action. Source of truth = join table; counter = cache.
EXPLAIN ANALYZE SELECT * FROM skills WHERE category = 'testing' ORDER BY trending_score DESC LIMIT 20;
apps/api/skillhub/services/skills.pylibs/db/skillhub_db/models/Record browser-based feature demos as GIFs via Playwright and optionally document them in docs/features/index.md. Trigger with "Demo <feature>" or "Demo and Document <feature>".
Use when creating service modules in apps/api/skillhub/services/
Use when writing API tests in apps/api/tests/
Use when implementing division-based access control on any endpoint
Use when adding services to docker-compose.yml or creating Dockerfiles
Use when implementing error handling across the API, frontend, or MCP server