Bulk Load Example
- Last UpdatedNov 18, 2025
- 2 minute read
- PI System
- AF SDK 2024 R2
- Developer
To achieve the best performance from AF, it is preferable to do operations such as loading AF SDK objects from the server, or retrieving attribute values in bulk. By using the bulk load methods of the AF SDK, the number of round trip Remote Procedure Calls (RPC's) to the server is reduced. Depending on your network characteristics such as latency and bandwidth, reducing RPC's can significantly increase the performance of your application. The following examples illustrate the use of some of the common bulk operations
In AF, SDK objects which can be checked-in, are considered top-level objects. These items can be loaded individually from the server or in bulk. Typically, when these items are first returned to the client application from a search or from accessing a collection, only the header information is returned. When your program accesses information that is not in the header, then the AF SDK will retrieve the full object definition from the server. If an application does this with many objects, many RPCs may result. The example, Loading Top Level Objects, uses the AFElementSearchFindElements method to illustrate a mechanism for bulk loading a list of objects into the client.
Because elements are organized into a hierarchy, there are frequently situations where an application is going to want an entire hierarchy loaded into the client memory space. The example, Loading Element Hierarchy, uses the LoadElementsToDepth method to illustrate a mechanism for bulk loading an entire hierarchy of elements into the client.
In some cases, when loading an element hierarchy into the client, more control is needed over the individual objects of the hierarchy which need to be loaded than LoadElementsToDepth provides. The example, Loading Partial Element Hierarchy, uses the LoadElementReferences method to illustrate a mechanism for loading the child elements for multiple elements at one time.
Typically, a top-level object in the AF SDK is either fully-loaded, or just has the header information for it loaded. Often, however, there is a need to just access a few specific attributes from a collection of elements. The example, Loading Partial Elements, uses the LoadAttributes method to load a specific list of attributes into the client. By only loading a partial set of attributes, the amount of information required to be transferred from the server to the client is reduced, resulting in faster performance and a lower memory footprint.
Retrieving values from AF Attributes is also best done in bulk, in particular, if any of the data is coming from PI. By bulk retrieving the data, the calls to the PI Data Archive server can be batched. The example, Retrieving Values, uses the AFAttributeList to illustrate how to retrieve attribute values in bulk.