22 - Graph Analytical View SQL Workflow¶
This example shows the intended Python posture for Graph Analytical Views: keep the binding surface thin and drive the entire lifecycle with SQL, even for a much larger synthetic transport graph. The default run now starts at six-figure scale.
It covers:
- generating a synthetic graph with 100,000 base
Cityvertices by default and a denser multi-regionROADtopology - creating a named Graph Analytical View with
VERTEX TYPES,EDGE TYPES,PROPERTIES, andEDGE PROPERTIES - polling
schema:graphAnalyticalViewsuntil the initial async build becomesREADY - inspecting metadata such as
status,nodeCount,edgeCount,compactionThreshold, andmemoryUsageBytes - running normal SQL
MATCHtraversals and aggregate queries without a Python-native GAV wrapper - showing how
UPDATE MODE OFFbecomesSTALEafter a large growth wave - rebuilding explicitly with
REBUILD GRAPH ANALYTICAL VIEW ... - altering the view with
ALTER GRAPH ANALYTICAL VIEW ... - switching to
UPDATE MODE SYNCHRONOUSand verifying live count changes on another growth wave - reopening the database to confirm persisted GAV restoration
Run¶
From bindings/python/examples:
With a custom database path:
The default run is 100,000 base cities, 25,000 stale-growth cities, and 10,000 synchronous-growth cities.
For a smaller smoke-sized run:
python3 22_graph_analytical_view_sql.py --base-cities 1200 --stale-growth-cities 300 --sync-growth-cities 200 --regions 12 --batch-size 300
Notes¶
- The example is deliberately SQL-first. It uses
db.command("sql", ...)anddb.query("sql", ...)only. CREATE GRAPH ANALYTICAL VIEW ...starts with an async build, so checkingschema:graphAnalyticalViewsis part of the expected workflow.- The script demonstrates both manual refresh (
UPDATE MODE OFF+REBUILD) and live refresh (UPDATE MODE SYNCHRONOUS). - The database is left on disk so you can reopen it and inspect the persisted GAV.
Why This Example Exists¶
The Java codebase already exposes Graph Analytical Views through SQL DDL and schema metadata. The Python binding therefore does not need a dedicated Graph Analytical View object API just to manage the feature. This example documents that decision in executable form at a more realistic scale, so users can see both the operational lifecycle and the tradeoff of keeping the Python surface thin.