batchSize
目的 Purpose
Customizes how many results are fetching during lazy loading.使用例 Examples
class Book {
…
static mapping = {
batchSize 10
}
}詳細 Description
Usage:
使用方法: batchSize(integer)Usage:
batchSize(integer)Given a lazy association where an Author has many Books, GORM will perform one query for the Author and additional queries the associated Books. This is what is known as the N+1 problem and can often be worked around by using a join query. However, joins can be expensive.Batch fetching is an optimization of lazy loading so that if, for example, you set a batchSize of 10 and you have an Author that with 30 books, instead of 31 queries you get four (one for the Author and three batches of 10):static mapping = {
batchSize 10
}batchSize on a per association basis:class Author { static hasMany = [books: Book] static mapping = {
books batchSize: 10
}
}
