The statistics collection function

The OpaqueStatCollect() function collects statistics (minimum value, maximum value, and distribution information) for the Opaque opaque data type when a user executes the UPDATE STATISTICS statement in medium or high mode.

The generated code

The OpaqueStatCollect() function calls the Opaque_SetMinValue(), Opaque_SetMaxValue(), and Opaque_SetHistogram() functions.

BladeSmith generates complete code for the OpaqueStatCollect() function. The OpaqueStatCollect() function is an iterator that processes each row in a table. It compiles statistical information by calling the Opaque_SetMinValue(), Opaque_SetMaxValue(), and Opaque_SetHistogram() functions. The OpaqueStatCollect() function stores statistical information in a multirepresentational type.

Customize the code

You must understand your data and how users will query it to create meaningful statistics. BladeSmith generates statistics code under the assumption that the minimum, maximum, and distribution of values are appropriate for your opaque data type; however, they might not be. In that case, you must rewrite the OpaqueStatCollect() function to call other functions that you provide.