🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
MaxFetch
This page was created by Hans.karlsen on 2017-02-02. Last edited by Wikiadmin on 2026-07-29.

MaxFetch lets you limit how many records a seeker search returns, so you can keep a broad search from loading more results than the user needs.

What MaxFetch does

MaxFetch is a tagged value that sets the maximum number of records returned by a search. If you do not define it, the default limit is 20 records.

For example, a seeker that could match thousands of persons can be configured with MaxFetch=100. The search then returns at most 100 matching records.

Use MaxFetch when users search large database tables. It encourages users to provide useful criteria before loading a large result set.

Add MaxFetch to a seeker search

Add the tagged value to the ViewModelColumn action that starts the search. This action commonly has EAL such as:

selfVM.Search

To configure the limit:

  1. In MDriven Designer, open the ViewModel that contains the seeker.
  2. Select the ViewModelColumn action that executes the search, usually the action whose EAL is selfVM.Search.
  3. Add the tagged value MaxFetch with an integer value.
  4. Save the ViewModel and test the search with criteria that return more records than the configured limit.

For example, to return no more than 100 records, declare:

MaxFetch=100
Tagged value Result
MaxFetch=20 Return at most 20 records.
MaxFetch=100 Return at most 100 records.
No MaxFetch tagged value Return at most the default of 20 records.

Choose an appropriate limit

Set a limit that supports the task without making an unfiltered search return an unnecessarily large result set.

For example:

  • A user searching for a customer by name may need 20 or 100 results.
  • A user searching a large history table should first narrow the search by date, status, or another criterion rather than relying on a high MaxFetch value.

MaxFetch limits returned records; it does not replace search criteria. Use search expressions to filter the result set before it is fetched.

Use paging when users need more results

MaxFetch is a result limit, not paging. If users need to work through all matching records, configure Search result pages. Paging uses seeker variables to determine the total number of matches and to fetch a selected page of results.

When paging is enabled, the seeker first performs a count(*) query to determine the total number of hits. The page length is controlled separately, and the user can move between pages. The seeker result grid must be identified with the tagged value IsSeekerResultGrid=true on its nesting. Paging is available in the WPF client and the Angular Turnkey client.

Related query mechanisms

MaxFetch as described on this page is a tagged value used by seeker search logic and by ExecutePS in its documented configuration.

Do not confuse this tagged value with the maxfetch parameter in PSEval and PSEvalTuples. Those operators specify the maximum result count directly in their expression, for example:

SysUser.PSEval(SysUser.allinstances->select(su|su.Username=userName), 2, 0, '')

In this example, 2 is the PSEval maximum fetch value and 0 is the zero-based offset. For new database-evaluated expressions, consider PSEval as described in ExecutePS.

See also