gorm-indexes

Create and manage GORM model index definitions including composite, unique, partial, expression, and shared options.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Indexes are essential for reducing query latency and preventing full table scans, but designing and applying the right indexes is error prone and can hurt write performance if done incorrectly. This Skill documents how to declare indexes in GORM model tags and apply them safely so queries that use WHERE, JOIN, or ORDER BY run significantly faster without unnecessary overhead.

Core Features & Use Cases

  • Declarative index definitions: Define basic and named indexes, unique constraints, and multiple indexes directly on struct fields using model tags.
  • Composite and shared indexes: Create multi-column indexes, control column ordering via priority, and use shared composite naming for embedded structs to avoid duplicates.
  • Advanced index options: Configure partial indexes, expression indexes, index type and class, collation, prefix length, comments, and database-specific options such as concurrent creation or parsers.
  • Practical use cases: Speed up search and lookup queries, enforce uniqueness across columns, reduce cost of frequent joins, and implement efficient partial indexes for active subsets of data.

Quick Start

Tag your model fields with index or uniqueIndex (and additional options) and run AutoMigrate to create the indexes in the database.

Frequently Asked Questions about gorm-indexes

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

FAQPage Schema
How do I create composite indexes in GORM model tags?

Create composite indexes in GORM by tagging multiple struct fields with the same index name. You can control column ordering using the priority option and run AutoMigrate to apply the multi-column index to the database.

Does GORM support partial and expression indexes?

Yes, GORM supports partial and expression indexes through model tag options. You can use the where option for partial indexes to target active data subsets, and the expression option to index based on specific expressions.

What is the best way to speed up GORM database queries for frequent joins and lookups?

Speed up GORM queries by declaring single or composite indexes on struct fields used in WHERE, JOIN, or ORDER BY clauses. AutoMigrate applies these indexes to the database, significantly reducing query latency and preventing full table scans.

Can I enforce uniqueness across multiple columns using GORM?

Enforce uniqueness across multiple columns in GORM by using the uniqueIndex tag on your struct fields. Tagging multiple fields with the same uniqueIndex name creates a composite unique constraint during AutoMigrate.

How do I configure database-specific index options like CONCURRENTLY in GORM?

Configure database-specific index options in GORM using model tag parameters. You can set options such as class, type, collate, prefix length, and custom options like CONCURRENTLY or custom parsers directly within the index tag definition.