{"id":18761027,"url":"https://github.com/go-gorm/hints","last_synced_at":"2025-08-13T19:30:57.796Z","repository":{"id":38040303,"uuid":"271415171","full_name":"go-gorm/hints","owner":"go-gorm","description":"Optimizer/Index/Comment Hints for GORM","archived":false,"fork":false,"pushed_at":"2024-09-14T12:54:46.000Z","size":70,"stargazers_count":40,"open_issues_count":0,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-07T18:11:53.034Z","etag":null,"topics":["gorm","hints"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/go-gorm.png","metadata":{"funding":{"github":["jinzhu"],"patreon":"jinzhu","open_collective":"gorm"},"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-11T00:36:03.000Z","updated_at":"2024-09-29T22:44:39.000Z","dependencies_parsed_at":"2024-04-29T08:27:08.241Z","dependency_job_id":"57685556-4233-480f-8e45-5aa19e4ca144","html_url":"https://github.com/go-gorm/hints","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-gorm%2Fhints","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-gorm%2Fhints/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-gorm%2Fhints/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-gorm%2Fhints/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-gorm","download_url":"https://codeload.github.com/go-gorm/hints/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229777192,"owners_count":18122465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gorm","hints"],"created_at":"2024-11-07T18:14:45.320Z","updated_at":"2024-12-15T03:04:26.280Z","avatar_url":"https://github.com/go-gorm.png","language":"Go","funding_links":["https://github.com/sponsors/jinzhu","https://patreon.com/jinzhu","https://opencollective.com/gorm"],"categories":[],"sub_categories":[],"readme":"# Hints\n\n![CI](https://github.com/go-gorm/hints/workflows/CI/badge.svg)\n\nOptimizer/Index/Comment Hints support for GORM\n\n## Optimizer Hints\n\n```go\nimport \"gorm.io/hints\"\n\nDB.Clauses(hints.New(\"hint\")).Find(\u0026User{})\n// SELECT * /*+ hint */ FROM `users`\n```\n\n## Index Hints\n\n```go\nimport \"gorm.io/hints\"\n\nDB.Clauses(hints.UseIndex(\"idx_user_name\")).Find(\u0026User{})\n// SELECT * FROM `users` USE INDEX (`idx_user_name`)\n\nDB.Clauses(hints.ForceIndex(\"idx_user_name\", \"idx_user_id\").ForJoin()).Find(\u0026User{})\n// SELECT * FROM `users` FORCE INDEX FOR JOIN (`idx_user_name`,`idx_user_id`)\"\n\nDB.Clauses(\n\thints.ForceIndex(\"idx_user_name\", \"idx_user_id\").ForOrderBy(),\n\thints.IgnoreIndex(\"idx_user_name\").ForGroupBy(),\n).Find(\u0026User{})\n// SELECT * FROM `users` FORCE INDEX FOR ORDER BY (`idx_user_name`,`idx_user_id`) IGNORE INDEX FOR GROUP BY (`idx_user_name`)\"\n```\n\n## Comment Hints\n\n```go\nimport \"gorm.io/hints\"\n\nDB.Clauses(hints.Comment(\"select\", \"master\")).Find(\u0026User{})\n// SELECT /*master*/ * FROM `users`;\n\nDB.Clauses(hints.CommentBefore(\"insert\", \"node2\")).Create(\u0026user)\n// /*node2*/ INSERT INTO `users` ...;\n\nDB.Clauses(hints.CommentAfter(\"select\", \"node2\")).Create(\u0026user)\n// /*node2*/ INSERT INTO `users` ...;\n\nDB.Clauses(hints.CommentAfter(\"where\", \"hint\")).Find(\u0026User{}, \"id = ?\", 1)\n// SELECT * FROM `users` WHERE id = ? /* hint */\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-gorm%2Fhints","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-gorm%2Fhints","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-gorm%2Fhints/lists"}