The Grails Framework 6.0.0

(Quick Reference) ## batchSize ### Purpose Customizes how many results are fetching during lazy loading. ### Examples
    class Book {
        ...
        static mapping = {
            batchSize 10
        }
    }
### Description Usage: `batchSize(integer)` Given a lazy association where an `Author` has many `Book` instances, GORM will perform one query for the `Author` and additional queries the associated `Book` instances. 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
    }
You can also configure `batchSize` on a per association basis:
    class Author {

        static hasMany = [books: Book]

        static mapping = {
            books batchSize: 10
        }
    }
| Quick Reference (hide)