1.16 RDF Support for Oracle Database In-Memory

RDF can use the in-memory Oracle Database In-Memory suite of features, including in-memory column store, to improve performance for real-time analytics and mixed workloads.

After Database In-Memory setup, the RDF in-memory loading can be performed using the SEM_APIS.ENABLE_INMEMORY procedure. This requires an administrative privilege and affects the entire RDF network. It loads frequently used columns from the RDF_LINK$ and RDF_VALUE$ tables into memory.

After this procedure is executed, RDF in-memory virtual columns can be loaded into memory. This is done at the RDF graph collection level: when an RDF graph collection is created, the in-memory option can be specified in the call to SEM_APIS.CREATE_RDF_GRAPH_COLLECTION.

You can also enable and disable in-memory population of RDF data for specified RDF graphs and inferred graphs by using the SEM_APIS.ENABLE_INMEMORY_FOR_RDF_GRAPH, SEM_APIS.ENABLE_INMEMORY_FOR_INF_GRAPH, SEM_APIS.DISABLE_INMEMORY_FOR_RDF_GRAPH, and SEM_APIS.DISABLE_INMEMORY_FOR_INF_GRAPH procedures.

Note:

To use RDF with Oracle Database In-Memory, you must understand how to enable and configure Oracle Database In-Memory, as explained in Oracle Database In-Memory Guide.

1.16.1 Enabling Oracle Database In-Memory for RDF

To load RDF data into memory, the compatibility must be set to 12.2 or later, and the inmemory_size value must be at least 100MB. The RDF network can then be loaded into memory using the SEM_APIS.ENABLE_INMEMORY procedure.

Before you use RDF data in memory, you should verify that the data is loaded into memory:

SQL> select pool, alloc_bytes, used_bytes, populate_status from V$INMEMORY_AREA;
POOL			   ALLOC_BYTES USED_BYTES POPULATE_STATUS
-------------------------- ----------- ---------- --------------------------
1MB POOL		    5.0418E+10 4.4603E+10 DONE
64KB POOL		    3202088960	  9568256  DONE 

If the POPULATE_STATUS value is DONE, the RDF data has been fully loaded into memory.

To check if RDF data in memory is used, search for ‘TABLE ACCESS INMEMORY FULL’ in the execution plan:

--------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation			  | Name      | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |    TQ  |IN-OUT| PQ Distrib |
--------------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT		  |	      |     1 |    13 |   580  (60)| 00:00:01 |       |       |        |      | 	   |
|   1 |  VIEW				  |	      |     1 |    13 |   580  (60)| 00:00:01 |       |       |        |      | 	   |
|   2 |   VIEW				  |	      |     1 |    13 |   580  (60)| 00:00:01 |       |       |        |      | 	   |
|   3 |    SORT AGGREGATE		  |	      |     1 |    16 | 	   |	      |       |       |        |      | 	   |
|   4 |     PX COORDINATOR		  |	      |       |       | 	   |	      |       |       |        |      | 	   |
|   5 |      PX SEND QC (RANDOM)	  | :TQ10000  |     1 |    16 | 	   |	      |       |       |  Q1,00 | P->S | QC (RAND)  |
|   6 |       SORT AGGREGATE		  |	      |     1 |    16 | 	   |	      |       |       |  Q1,00 | PCWP | 	   |
|   7 |        PX BLOCK ITERATOR	  |	      |   242M|  3697M|   580  (60)| 00:00:01 |KEY(I) |KEY(I) |  Q1,00 | PCWC | 	   |
|   8 | 	TABLE ACCESS INMEMORY FULL| RDF_LINK$ |   242M|  3697M|   580  (60)| 00:00:01 |KEY(I) |KEY(I) |  Q1,00 | PCWP | 	   |
--------------------------------------------------------------------------------------------------------------------------------------------

To disable in-memory population of RDF data, use the SEM_APIS.DISABLE_INMEMORY procedure.

1.16.2 Using In-Memory Virtual Columns with RDF

In addition to RDF data in memory, RDF in-memory virtual columns can be used to load lexical values for RDF terms in the RDF_LINK$ table into memory. To load the RDF in-memory virtual columns, you must first execute SEM_APIS.ENABLE_INMEMORY with administrative privileges, setting the inmemory_virtual_columns parameter to ENABLE. The in-memory virtual columns are created in the RDF_LINK$ table and loaded into memory at the RDF graph collection level.

To load the virtual columns into memory, use the option ‘PXN=F INMEMORY=T’ in the call to SEM_APIS.CREATE_RDF_GRAPH_COLLECTION. For example (assuming a schema-private network named NET1 owned by a database user named RDFUSER):

EXECUTE  SEM_APIS.CREATE_RDF_GRAPH_COLLECTION ('vm2',SEM_MODELS('lubm1k','univbench'),SEM_RULEBASES ('owl2rl'),options=>'PXN=F INMEMORY=T', network_owner=>'RDFUSER', network_name=>'NET1');

You can check for in-memory RDF graph collections by examining the SEM_MODEL$ view, where the INMEMORY column is set to T for an in-memory graph collection.

The in-memory RDF graph collection removes the need for joins with the RDF_VALUE$ table. To check the usage of in-memory RDF graph collections, use the same commands in Enabling Oracle Database In-Memory for RDF.

For best performance, fully populate the in-memory virtual columns before any query is processed, because unpopulated virtual columns are assembled at run time and this overhead may impair performance.

1.16.3 Using Invisible Indexes with Oracle Database In-Memory

Sometimes, inconsistent query performance may result due to the use of indexes. If you want consistent performance across different workloads, even though it may mean negating some performance gains that normally result from indexing, you can make the RDF network indexes invisible so that the query execution is done by pure memory scans. The following example makes the RDF network indexes invisible in a schema-private network named NET1 owned by a database user named RDFUSER:

EXECUTE SEM_APIS.ALTER_RDF_INDEXES('VISIBILITY','N', network_owner=>'RDFUSER', network_name=>'NET1');

To make the RDF network indexes visible again, use the following

EXECUTE SEM_APIS.ALTER_RDF_INDEXES('VISIBILITY','Y', network_owner=>'RDFUSER', network_name=>'NET1');

Note:

RDF_VALUE$ indexes must be visible so that Oracle Database can efficiently look up VALUE_IDs for query constants at compile time.

For an explanation of invisible and unusable indexes, see Oracle Database Administrator's Guide.