英文:
Is it possible to create an index concurrently in Postgres using GORM?
问题
PostgreSQL允许使用concurrently选项创建索引(https://www.postgresql.org/docs/9.1/sql-createindex.html)。
这样可以在构建索引时不锁定表。是否可以让gorm使用这个选项?
另外,AutoMigrate()的默认行为是什么?它会等待索引成功构建后再返回吗?
英文:
Postgress allows creating indexes with the concurrently option
(https://www.postgresql.org/docs/9.1/sql-createindex.html).
This allows building the index without locking the tables.
Is it possible to allow gorm to use this option?
On the other end, what is the default behavior of AutoMigrate() will it wait until the index is successfully built before returning?
答案1
得分: 0
已经实现了该功能,现在可以通过结构元数据添加CONCURRENTLY选项:
// PostgreSQL选项
type User struct {
Name string `gorm:"index:,option:CONCURRENTLY"`
}
- 文档:https://gorm.io/docs/indexes.html
- Github拉取请求:https://github.com/go-gorm/postgres/pull/47
英文:
The feature has been implemented and now is possible to add the CONCURRENTLY option via the struct metadata:
// PostgreSQL option
type User struct {
Name string `gorm:"index:,option:CONCURRENTLY"`
}
- Docs: https://gorm.io/docs/indexes.html
- Github Pull Request: https://github.com/go-gorm/postgres/pull/47
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论