Using setLimit() method, one can restrict the number of records pulled in from the database. Suppose you want to check if a record exists or not, in such cases, you could use setLimit(1) to ensure if found, only one record will be returned. Or if you are working on portal with paginated data, always fetch only those many records that you would show up on a page at time.
This will ensure lighter database queries and returns.
Of course, records will get into fisticuffs to ensure they get in first.
Comments
Post a Comment