Using a global index

[Version 8.6 and later]Implementing a global index can improve searching data performance in large partitioned environment, for example 100 partitions.

The feature also provides a way to find locations of indexed attributes and can improve agents or queries operations that are related to indexed attributes. Refer to the MapGlobalIndex API documentation for details of global index capabilities.

Improved performance

In a large partitioned environment, cached objects are spread across all partitions. Any search for data with indexes, queries, or agents, would need to run against all servers to be able to get a complete result. This type of search is slow because of the remote calls that are required to load and search each partition. Also, not all partitions have the data that matches the search criteria. The global index improves search performance because it only runs searches against those partitions that actually have matching data. The global index feature can track the location of indexed attributes and can determine applicable partitions for attributes from all partitions. Usually, applicable partitions are a subset of all partitions. Therefore, running indexes, queries, and agents on applicable partitions are much faster than running these items on all partitions, even when offset by global index.

Searching data

Applications can search for data with keys. Applications can also search for data with indexes if the data has one or more attributes and indexes are defined for the attributes. Traditionally, applications can use a client index proxy to get entry keys from all partitions, or use an agent to do an index search on all partitions and return cache keys, values, or both. With the global index feature, applications can find entry keys, values, or both through the MapGlobalndex API in an efficient approach that runs operations on applicable partitions only.

Agent operation

If an agent operation is related to indexed attributes, for example, by invalidating entries using indexed attributes, applications can use global index to find applicable partitions by attributes first. Then the application can send the agent to these applicable partitions. Use the MapGlobalndex.findPartitions() method to find applicable partitions using attributes.

Client query operation

When you run client queries, you must set partitions. Usually, the application must run the same query on all partitions to get complete query results. With the global index feature, applications can use the MapGlobalndex.findPartitions() method to find applicable partitions using attributes that are in equality predicates of query. Then, you can run the query on these applicable partitions.

Enabling a global index

Global index is an extension of the HashIndex plug-in and can be enabled on any existing HashIndex configuration. Using XML configuration as an example, setting the GlobalIndexEnabled property of the HashIndex plug-in to true enables global index on that HashIndex plug-in.
<bean id="MapIndexPlugin" 
      className="com.ibm.websphere.objectgrid.plugins.index.HashIndex">
         <property name="Name" type="java.lang.String" value="CODE" 
            description="index name" />
         <property name="AttributeName" type="java.lang.String" value="employeeCode" 
            description="attribute name" />
 	<property name="GlobalIndexEnabled" type="boolean" value="true" 
            description="true for global index" />
   </bean>

Performing a global index lookup

The global index function is defined in the MapGlobalIndex API. After the global index is enabled on a HashIndex plug-in, the application can cast an obtained index proxy to the MapGlobalIndex type and start using it.
// in client ObjectGrid process
MapGlobalIndex mapGlobalIndexCODE = (MapGlobalIndex)m.getIndex("CODE", false);
Object[] attributes = new Object[] {new Integer(1)};
Collection partitions = mapGlobalIndexCODE.findPartitions(attributes);
Set keys = mapGlobalIndexCode.findKeys(attributes);
Set values = mapGlobalIndexCode.findValues(attributes);
Map entries = mapGlobalIndexCode.findEntries(attributes);

Migration and interoperability

The only restriction for using global index is that an application cannot configure it in a distributed environment with heterogeneous containers. Old and new container servers cannot be mixed, since older container servers do not recognize a global index [Version 8.6.0.2 and later]or a composite global index configuration.

Before you can use a global index[Version 8.6.0.2 and later]or a composite global index, you must stop all container servers, clients, and applications first. Then, you can enable a global index on HashIndex configuration, and restart your environment.