1.为了在查询中获得最佳性能,通常需要定制表索引定义 这就需要用到‘index’约束
class Person {
String firstName
String address
static mapping = {
table 'people'
version false
id column: 'person_id'
firstName column: 'First_Name', index: 'Name_Idx'
address column: 'Address', index: 'Name_Idx,Address_Index'
}
}
请注意,在 index属性的值中不能有任何空格,在这个例子中index:'Name_Idx, Address_Index'会导致错误
本文介绍了一种通过自定义表索引定义来提高数据库查询性能的方法,具体展示了如何使用‘index’约束来创建复合索引,并强调了索引属性值中不能包含空格的重要性。
345

被折叠的 条评论
为什么被折叠?



