gorm-hints

Add optimizer, index, and comment hints to GORM queries.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/liurida/gorm-development-skill --skill gorm-hints
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gorm-hints
Source: https://github.com/liurida/gorm-development-skill/tree/main/hints
Command: npx skills add https://github.com/liurida/gorm-development-skill --skill gorm-hints

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

GORM queries can suffer from suboptimal execution plans, leading to slower performance or incorrect routing in multi‑tenant databases. Without explicit hints, developers cannot guide the database optimizer or force specific indexes.

Core Features & Use Cases

  • Optimizer Hints – Direct the database optimizer (e.g., MAX_EXECUTION_TIME, parallel) to control execution behavior.
  • Index Hints – Suggest, force, or ignore indexes for SELECT, JOIN, ORDER BY, and GROUP BY clauses.
  • Comment Hints – Attach custom SQL comments for routing, debugging, or monitoring purposes.
  • Use Cases – Tuning slow queries, enforcing index usage in complex joins, routing read/write traffic in read‑replica setups, and adding traceable comments for observability.

Quick Start

"Add an index hint that forces the idx_user_name index when querying the User model."

Frequently Asked Questions about gorm-hints

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

FAQPage Schema
How do I force a specific index in GORM to fix slow queries?

You can force a specific index in GORM by adding index hints to your queries, suggesting or forcing indexes for SELECT, JOIN, ORDER BY, and GROUP BY clauses to correct suboptimal execution plans without modifying application logic.

What are optimizer hints and when do I need them for SQL queries?

Optimizer hints are directives that guide the database optimizer's execution behavior, such as setting MAX_EXECUTION_TIME. You need them when fine-tuning query performance or enforcing specific indexes to resolve inefficient execution plans.

Can I use GORM to route read and write traffic in a multi-tenant database?

Yes, you can route queries in multi-tenant or read-replica environments by attaching custom SQL comment hints to GORM queries, allowing you to direct traffic and add traceable comments for routing and observability.

How do I add SQL comments to GORM queries for monitoring?

You can add custom SQL comments to GORM queries by leveraging comment hints, attaching database-specific directives for routing, debugging, or monitoring purposes to improve system observability.

Does GORM support database-specific hints without changing application code?

Yes, GORM supports database-specific hints through the gorm.io/hints package, allowing you to inject optimizer, index, and comment directives directly into queries without modifying your existing application logic.