Structural differences between optimized and default stores
Optimized stores and default stores differ structurally in two of their tables: the Direct Primary (DP) and Reverse Primary (RP) tables. All other tables of the RDF store are the same for default and optimized stores. The differences in DP and RP tables in an optimized store can help speed up insert and query performance. To understand the differences in the structure of the stores, you must understand how the predicates are mapped to the columns and are stored in the underlying tables.
A DP table stores the RDF triples and the graph they belong to, indexed by subject. Predicates and objects for a subject are stored in pair columns in this table. A particular predicate can occur in any one of three columns in this table. The object for that predicate is stored in the corresponding object column of the predicate-object pair.
Compared to a DP table in a default store, a DP table in an optimized
store has fewer columns and fewer null values. The DP table in the
default store you created in Part 1 has 128 pairs of
predicate and object columns (
prop XXX, val XX). Many
columns have null values, as shown. The DP table in the optimized
store you just created has only eight pairs of predicate and
object columns and, of course, far fewer null values.
An RP table stores the RDF triples and the graph that they belong to, indexed by object. Predicates and subjects for an object are stored in pair columns in this table. A particular predicate can occur in any one of three columns in this table, and the subject for that predicate is in the corresponding subject column of the pair.
Figure 3. Data in the direct primary table in default and optimized stores
Comparing the tables in the optimized store and default store reveals that:
- Fewer columns and fewer null values are required in the optimized store.
- You have faster insert operation and improved query performance.
If you compare the RP tables in the default and optimized stores you created, you will notice the same pattern of fewer columns and better utilization in the optimized store, as shown below.
Figure 4. Data in the Reverse Primary table in default and optimized stores
An optimized store can handle new predicates you add to the store (predicates that were unavailable during the predicate correlation calculation).
If you add predicates, the optimized store automatically and transparently uses hash functions to determine the column positions for the new predicates. Therefore, an optimized store can use a mixture of predicate correlation and hashing for the assignment of predicates to columns in the primary tables.
From the perspective of store maintenance in the DB2 database and application development, there is no difference between a default store and an optimized store. You do not have to develop an application differently depending on whether it uses an optimized store or a default store.