Optimize Property (ADO)

           

Indicates whether an index should be created on this field.

Settings and Return Values

Sets or returns a Boolean value.

Remarks

An index can improve the performance of operations that find or sort values in a Recordset. The index is internal to ADO—you cannot explicitly access or use it in your application.

The Optimize property is "dynamic"; it is not a part of the Field object interface. It exists only in a Field object's Properties collection, provided that you set the CursorLocation property to adUseClient.

To create an index on a field, set the Optimize property to True. To delete the index, set this property to False. If some operation implicitly creates an index on this field, then the operation will set the Optimize property to True.

Usage

Recordset   rs = New ADOB.Recordset
Field       f = New ADODB.Field
rs.CursorLocation = adUseClient   'Enable index creation
rs.Open ...
set f = rs.Fields(0)
f.Properties("Optimize") = TRUE   'Create an index
f.Properties("Optimize") = FALSE   'Delete an index