Oracle Graph Server and Client 22.2, the second release in 2022, has several exciting new features. All features work with Oracle Database 12.2 onward, with the download of Graph Server and Client.
Feature Highlights
Subgraph Loading
The in-memory Graph Server (PGX) enables extremely fast, scalable graph analytics. Developers often ask, “Should I load the whole graph into memory?” With Oracle Graph Server and Client 22.2, the answer is that now you can load only the subgraph you want and dynamically expand it as needed. So, an application might require less memory.
Here is an example of the API:
PgxGraph graph = session.readSubgraph()
.fromPgView(pgViewName)
.asOfScn(“1234”)
.queryPgql(“MATCH (a:person)”)
.queryPgql(“MATCH (b:car)”)
.load();
Then, to dynamically expand the graph:
PgxGraph expandedGraph = g.expandGraph()
.withPgql()
.fromPgView(pgViewName)
.queryPgql(“MATCH (a:person)-[:owns]>(b:car) WHERE a.age > 33”)
.vertexPropertiesMergingStrategy(UPDATE_WITH_NEW_VALUES)
.edgePropertiesMergingStrategy(KEEP_CURRENT_VALUES)
.expand()
More details are available here.
PGQL on PG Views: INSERT, UPDATE, and DELETE
One of the significant advantages of Property Graph views (PG views) is using SQL to insert new vertices or edges into the graph or update existing properties. Such updates to graph data can be made on the underlying tables using SQL – making it easy for applications to continue to insert/update data as before to the tables – and the updates will be instantly available in the PG view graph.
However, it is also advantageous to have the ability to make updates to the graph using PGQL, which is a graph query language, so that the same language can be used for queries and updates of PG view graphs. With this release, developers can update PG view graphs using PGQL INSERT, UPDATE, and DELETE statements. Note that this is already supported for graphs loaded into memory in the Graph Server.
Examples:
INSERT EDGE t
BETWEEN a1 AND a2
LABELS ( transaction )
PROPERTIES ( t.amount = 20.00 )
FROM MATCH (a1:Account),
MATCH (a2:Account)
WHERE a1.number = 2090 AND a2.number = 8021
UPDATE t SET ( t.amount = 990.00 )
FROM MATCH (a1:Account) -[t:transaction]-> (a2:Account)
WHERE a1.number = 2090 AND a2.number = 10039
DELETE a
FROM MATCH (a:Account)
WHERE a.number = 2090
More details are available here.
The ALL Keyword when Using PGQL with PG Views
Another feature for graphs in the Graph Server and is now added to PG views graphs is the keyword ALL to find all paths between a pair of vertices. When the graph is a tree, ALL can be used instead of SHORTEST (since there is only one path between vertices in trees) for a significant performance boost.
Example:
SELECT LISTAGG(e.amount, ' + ') || ' = ', SUM(e.amount) AS total_amount
FROM MATCH ALL (a:Account) -[e:transaction]->{,7} (b:Account)
WHERE a.number = 10039 AND b.number = 2090
ORDER BY total_amount
More information on ALL, and other PGQL features that work with PG views, are here.
Graph Visualization Enhancements
Developers can use simple syntax to fetch all properties of a vertex/edge (instead of listing each of them) using the SELECT n.* syntax in the graph visualization tool.
PROPERTY_GRAPH_METADATA
A metadata graph, called PROPERTY_GRAPH_METADATA will contain information about PG view graphs in the database and is itself a graph. To get all vertex property names of the graph BANK_GRAPH:SELECT p.property_name
FROM MATCH (g:property_graph)
-[:has_vertex_table]-> (:vertex_table)
-[:has_label]-> (:label)
-[:has_property]-> (p:property)
ON property_graph_metadata
WHERE g.graph_name = 'BANK_GRAPH'
Source: oracle.com
0 comments:
Post a Comment