Platform SDK: Active Directory, ADSI, and Directory Services

Paging

Paging specifies how many rows at a time the server returns to the client. A page can be defined by the number of rows or a time limit. The ADSI COM object takes care of retrieving each page of results based on the following settings. The caller simply calls IDirectorySearch::GetNextRow when the caller has reached the end of a page, and the ADSI COM object takes care of retrieving the next page.

ADS_SEARCHPREF_PAGESIZE
Specifies the number of rows to return in a page.
ADS_SEARCHPREF_PAGED_TIME_LIMIT
Specifies the maximum time (in seconds) that the server should spend collecting a page of results before returning the page to the client. If the limit is reached, the server stops searching and returns the rows retrieved for the page up to that point.

If neither of these search preferences is set, the default is no paging.

A search operation may result in a return of a large number of objects. If the server returns the result in one big chunk, it could downgrade the performance of the client and server as well as the network load. Paged search can be used to prevent this from happening. In a paged search, the client may elect to accept results in smaller chunks. The size of a chunk is known as the search page size.

Paged search offers benefits to both the client and the server. The client can be more responsive in presenting the results to end users. This is especially relevant to graphical user interface tools that can begin the window display process while the other thread concurrently receives the data.

On the server side, paged search makes the operation scalable. Suppose that one hundred clients issue search requests simultaneously and, on the average, each client gets back two hundred objects. If no page size is specified, the server must have sufficient memory to hold 20,000 objects in the worst case scenario. On the other hand, if each client specifies a page size to be, say, ten (10) objects, the memory requirement on the server is thus reduced by a factor of 20.

In addition, using a paged search, a client can abandon the operation in progress. In contrast, in a non-paged search, the client receives a result set in one big chunk. This may potentially put a heavy burden on the network.

On behalf of the client, ADSI handles the page size transparently. The client does not have to count the number of objects in progress. ADSI encapsulates the server interaction for the client. From the client's perspective, the search comes back with a complete result set.

It is recommended that you turn on paging.