All posts Insight

Run Cypher graph queries on dataframes faster with new GFQL indexes

Run Cypher graph queries on dataframes faster with new GFQL indexes

A Cypher query over 50 account IDs drops from 2.7 seconds to 5 milliseconds. A search across 30M timestamps responds in 101 ms instead of 40 seconds.

 

Quick refresher: GFQL runs openCypher on your dataframes

GFQL is an open-source Cypher engine for CPUs and GPUs. It already beats Kuzu, Memgraph and Neo4j on popular graph benchmarks. Better yet, your queries run directly on the dataframes you already have, without a graph database to deploy or operate.

You write openCypher (MATCH … WHERE … RETURN …) or the equivalent Python API. The query runs in your process on pandas, Polars, or GPU dataframes through RAPIDS cuDF. Nodes and edges stay in your dataframes, and results come back as dataframes. There is no separate database import. GFQL ships in PyGraphistry: pip install graphistry.

Use it in a notebook, an application or an AI agent that needs to query relationships in existing data. An agent can issue Cypher in one tool call and get data back, without managing a database session. Queries are validated before they run, and gfql_explain reports which indexes they used.

For a full example, see Cypher graph filtering and PageRank on dataframes.

Updates since the polars-gpu launch

The polars-gpu launch added indexes for hops and node ids. The 0.59.x releases add property indexes and let more queries use them. Here is what each kind covers:

 

Index What it speeds up Example
edge_out_adj Outgoing hops from known nodes CREATE GFQL INDEX FOR edge_out_adj;
MATCH (a {id: 101})–>(b) RETURN b
edge_in_adj Incoming hops to known nodes CREATE GFQL INDEX FOR edge_in_adj;
MATCH (a {id: 102})<–(b) RETURN b
node_id Lookups on the graph’s node id column CREATE GFQL INDEX FOR node_id;
MATCH (a {id: 101}) RETURN a
node_prop Filters on a node property CREATE GFQL INDEX FOR node_prop ON (account_number);
MATCH (a {account_number: 48213})–>(b) RETURN b
edge_prop Filters on an edge property CREATE GFQL INDEX FOR edge_prop ON (transaction_id);
MATCH (a)-[e {transaction_id: ‘txn-101’}]->(b) RETURN b

 

Our indexing demo notebook shows examples you can run based on the discussion in this post.

The release adds more than new kinds of indexes. It also expands which data types are indexable, so node and edge property indexes can now use text, nullable integers, categoricals, timestamps and exact float keys. Likewise, as part of GFQL enabling you to declaratively write multi-stage graph compute pipelines, you can now build indexes on-the-fly at any stage. Finally, this release also speeds up multi-attribute filters, like those you’d use in a search bar.

The following sections show how to create and use the indexes:

  • Build an index and query in one call, including inside graph pipelines.
  • Start a query from a list of ids and follow their edges with resident indexes.
  • Look up business keys on nodes or edges, using the new property-key types.
  • Check each query step with gfql_explain to see which indexes it used.
  • Speed up whole-graph timestamp search with the separate index used by searchAny.
Figure: 4x–518x faster lookups from ids and properties, plus whole-graph search. All measurements on an NVIDIA GB10.

Figure: 4x–518x faster lookups from ids and properties, plus whole-graph search. All measurements on an NVIDIA GB10.

Composable indexes

Build an index and use it in the same call. Lists of ids automatically use the node-id and adjacency indexes:

g.gfql(“CREATE GFQL INDEX IF NOT EXISTS FOR edge_out_adj; “
      “CREATE GFQL INDEX IF NOT EXISTS FOR node_id; “
      “MATCH (u)-[e]->(other) WHERE u.id IN [101, 102] RETURN other”)

Property indexes work the same way for business keys on nodes and edges. Pipelines can build indexes after narrowing a graph and reuse them in later stages. See the indexing notebook for both examples.

Check which indexes a query used

gfql_explain shows which indexes each query step used. When a step scans, a reason code helps you or an AI agent decide what to change:

report = g.gfql_explain(“MATCH (u {id: 101})-[e]->(other) RETURN other”)
report[“used_index”]   # True

In pipelines, inspect report[“steps”]; used_index is true if any stage used an index.

GFQL compares well with indexing in other graph databases

Figure: GFQL indexes outperforming Kuzu, Memgraph, Neo4j in low latency workloads.

Figure: GFQL indexes outperforming Kuzu, Memgraph, Neo4j in low latency workloads.

Whole-graph search that stays interactive

searchAny(n, term) matches one term against every column of an entity at once. It is what a whole-graph text search box runs on, such as the search field in the Graphistry UI, and g.search_nodes() / g.search_edges() call it from Python.

Matching search queries against formatted UI text rather than raw data used to require converting every timestamp to text. At 30M rows, that took roughly 40 seconds. GFQL can now reuse an index built once for the timestamp column, allowing each typed character to skip reformatting the entire column.

In the measurements for the 0.59.1 release, typing the first character, 2, into a search box gave these results on an NVIDIA GB10:

rows build (once) first keystroke render and scan ratio
1M 77 ms 3.4 ms 1,347 ms 396x
10M 797 ms 33.8 ms 13,323 ms 394x
30M 2,359 ms 101.3 ms 40,314 ms 398x

pandas uses this index, and cuDF uses it for UTC timestamps. Polars formats the timestamp column for each search, so searches at tens of millions of rows take longer.

Also in this release

See the changelog for the full release notes.

For documentation around indexes, see also:

  • Indexes, index DDL, index_policy, gfql_explain and the reason codes: the GFQL Indexing page.
  • searchAny, number and timestamp display rules, temporal_tz, and the IN null contract: the GFQL Cypher Syntax page.

Next

There is always more to do – if there is a query shape you need to go faster, tell us on Discord. Meanwhile, you can get started with this comparison.

Notes from the trenches, monthly.

Graph analytics, GPU viz, and the occasional war story. No spam.