When a query-type dataset returns a result set, it also receives a cursor, or pointer to the first record in that result set. The record pointed to by the cursor is the currently active record. The current record is the one whose field values are displayed in data-aware components associated with the result set's data source. Unless you are using dbExpress, this cursor is bi-directional by default. A bi-directional cursor can navigate both forward and backward through its records. Bi-directional cursor support requires some additional processing overhead, and can slow some queries.
If you do not need to be able to navigate backward through a result set, TQuery and TIBQuery let you improve query performance by requesting a unidirectional cursor instead. To request a unidirectional cursor, set the UniDirectional property to True.
Set UniDirectional before preparing and executing a query. The following code illustrates setting UniDirectional prior to preparing and executing a query:
if not (CustomerQuery.Prepared) then begin CustomerQuery.UniDirectional := True; CustomerQuery.Prepared := True; end; CustomerQuery.Open; { returns a result set with a one-way cursor }
if (!CustomerQuery->Prepared) { CustomerQuery->UniDirectional = true; CustomerQuery->Prepared = true; } CustomerQuery->Open(); // Returns a result set with a one-way cursor
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|