Data Source Statistics
PuppyGraph uses statistics to optimize query plans. Table statistics summarize the data in a table, such as how many rows it has and how the values in its columns are distributed. Collecting statistics for a table is called analyzing it.
This page covers:
- Why statistics matter: queries can be much slower without them.
- How to check statistics and collect them manually.
- What collecting statistics costs.
- Options for large and multi-tenant Iceberg tables.
Why statistics matter
A graph query usually reads several tables. Statistics let PuppyGraph estimate how many rows each step of the query returns, so it can start from the most selective step and keep intermediate results small. When a table has no statistics, queries still return the same results, but PuppyGraph has to plan them without these estimates, and multi-hop queries on large tables can be much slower or use much more memory.
PuppyGraph collects statistics automatically, so in most deployments you don't have to do anything. Check them after you upload a new schema, after a large change to the data, or when a query is slower than expected.
Which tables can be analyzed
PuppyGraph analyzes local tables and tables in these external catalogs: JDBC catalogs, such as PostgreSQL, MySQL or SQL Server, and Iceberg, Delta Lake, Hive and Hudi catalogs. Catalogs of these types that use ADBC connectivity, and catalogs of other types, can't be analyzed. For local tables, see Collecting statistics (Analyze). The rest of this page is about tables in external catalogs.
How statistics are collected
PuppyGraph collects statistics in the background. Collection never blocks a schema upload or a query.
- When a schema is uploaded, PuppyGraph analyzes the tables the graph reads that are missing statistics or the histograms the graph needs. Statistics of the whole table and histograms that already exist aren't collected again. Grouped statistics follow their own rule, described under Grouped analysis.
- After queries read a table, PuppyGraph analyzes it in the background, and analyzes it again periodically while queries keep reading it.
- You can analyze a table at any time from the Web UI. See Collecting statistics manually.
Checking statistics
Version requirement
The Freshness column and the Statistics state panel are available in PuppyGraph 1.20.0 and later.
On the Graph page, click Statistics in the toolbar. The view lists every table the graph reads, with the labels that use it, its Readiness and Freshness, the columns that have Histograms, its Rows, when statistics were Last collected, and the Latest jobs. A badge on the Statistics button counts the tables that Analyze missing would analyze.
Readiness is one of:
| Readiness | Meaning |
|---|---|
| Ready | The table has statistics and all the histograms the graph needs. |
| Histograms missing | The table has statistics, but some of the columns that hold node IDs or that edges connect on have no histogram yet. |
| Missing | The table has no statistics. Queries that read it can be slow. |
| Collecting | The table has no statistics yet, and an analyze of it is pending or running. |
| Not supported | The table is in a catalog that can't be analyzed. |
Freshness shows, for an Iceberg table, whether its statistics still describe the table as it is now. Current means the table's data hasn't changed since the statistics were collected. Stale means it has, and shows how many commits it is behind when PuppyGraph can count them. Queries can keep using stale statistics, but after significant changes to the data the estimates can be off, and analyzing the table again helps. Other tables show Not tracked.
Latest jobs shows the most recent job of each kind for the table, such as Basic or Histogram, and its status. To see all recent analyses of a table, open its row menu and choose View history. Each job in Analyze History shows its status (PENDING, RUNNING, SUCCESS or FAILED), when it started and finished, and, for a failed job, the reason. History is kept for three days.
Collecting statistics manually
In the Statistics view:
- Analyze missing analyzes every table that is missing statistics or histograms and isn't being analyzed already.
- Analyze selected analyzes the tables you select.
- Analyze now, in a table's row menu, analyzes that table, even if it already has statistics. Use it to refresh stale statistics.
You can also click Analyze Table in the Analyze Table dialog of a table.
Analyze a table again after a large change to its data, for example a bulk load, or when its Freshness shows Stale and its queries have become slower. Collection runs in the background and can take minutes on large tables. Its progress shows in Readiness and Latest jobs.
When role-based access control is enabled, analyzing a table requires DATA:write. See RBAC.
What collecting statistics costs
A full analyze reads the whole table, including columns the graph doesn't map. Columns of a type PuppyGraph can't read are skipped.
- For a lakehouse table (Iceberg, Delta Lake, Hive, Hudi), this is a scan of the table's files.
- For a table in a database catalog (a JDBC catalog such as PostgreSQL, MySQL or SQL Server), analyzing reads the table from the database several times, about once per column, so analyzing a wide table puts noticeable load on the database.
Automatic collection after queries repeats this periodically, as long as queries keep reading the table. If the source database serves production traffic, plan for this load. To turn off this automatic collection, set the environment variable AUTO_ANALYZE_EXTERNAL_CATALOG=false, and analyze tables manually when their data has changed significantly. Without statistics, queries can be much slower, so only turn it off if you analyze tables yourself.
Each analyze can run for up to one hour. An analyze that runs longer fails, and its reason in Analyze History says so. To allow more time, set the environment variable STATISTICS_ANALYZE_TIME_BUDGET to a duration in seconds, such as 5400s or 2h, and restart PuppyGraph. For a large partitioned Iceberg table, incremental analysis keeps the partitions it finished reading, so the next analyze continues from there.
Grouped analysis reads the table a second time, and uses more memory as the number of groups and statistics columns grows.
Large and multi-tenant Iceberg tables
For tables in Iceberg catalogs that don't use ADBC connectivity, two options change how a table is analyzed. You choose them per table in its analyze settings. A table can use one of them, not both.
Incremental analysis
An incremental analyze of a partitioned Iceberg table reads only the partitions that are new or changed since they were last analyzed, and keeps what it collected even if it stops before reading every partition. Use it for large partitioned tables whose full analyze takes too long. If Analyze History says partitions are left, analyze the table again to continue. If it reports a partition too large to read in time, raise STATISTICS_ANALYZE_TIME_BUDGET (see What collecting statistics costs). In the Statistics view, the table's Freshness shows how many of its partitions are current, stale, and not analyzed yet.
Grouped analysis
When one table holds the data of many logical partitions, such as the data of many tenants or stores, statistics for the whole table can be badly wrong for a single partition. Grouped analysis collects separate statistics for each group of rows that share the values of one or more grouping columns, such as store_id.
For example, an orders table holds the orders of many stores, and a query asks for the refunded orders of store 12. If store 12 has no refunded orders but other stores do, statistics for the whole table suggest many matching rows, and PuppyGraph may plan the query from the wrong end. With store_id as a grouping column and is_refunded as a statistics column, PuppyGraph knows that store 12 has almost no matching rows and starts the query from that filter.
A query can use grouped statistics only when it fixes every grouping column of the table to a single value, either in a WHERE condition such as store_id = 12, or with a logical partition such as logicalPartition: { store_id: 12 }. Other queries use the statistics of the whole table. Grouped statistics improve the estimates of equality filters on statistics columns, such as is_refunded = true. Other filters, such as ranges, are estimated from the statistics of the whole table.
To set it up, choose the table's grouping columns and statistics columns in its analyze settings:
- Grouping columns define the groups. If a mapping's filter fixes a column to a constant, such as
store_id = 12, PuppyGraph uses that column as a grouping column automatically. - Statistics columns are the columns that queries filter the table on. The columns that hold node IDs and that edges connect on are always included.
A grouped analysis stores at most 20,000 groups per table by default. A table with more groups fails its grouped analysis, and Analyze History gives the reason. The cap limits how many groups are stored, not the memory or time a collection uses. To allow more, set the STATISTICS_GROUPED_ANALYZE_MAX_GROUPS environment variable on the leaders and restart them: with -e for docker run, or in the Helm chart values under env.leader for a cluster or env.singleNode for a single-node install.
Grouped statistics are refreshed when you analyze the table manually, not by the automatic collection after queries. A schema upload collects them only when the table has none yet or its grouping or statistics columns changed. For a table whose groups change a lot, analyze it again after large batches of writes.
The Analyze Table dialog
The Analyze Table dialog shows the statistics of one table, its analyze settings and its Analyze History. To open it, on the Graph page, click Statistics in the toolbar, open the menu of the table's row, and choose View history. You can also click Catalog in the toolbar of the Graph page and click the Analyze Table icon on the table's row in the catalog tree.
Statistics state shows whether the table's statistics are current or how many commits behind they are, the same way as Freshness in the Statistics view.
For tables in Iceberg catalogs that don't use ADBC connectivity, the dialog also has the table's analyze settings:
- Analyze mode: Deployment default (full analysis unless your deployment is configured otherwise), Full, or Incremental. See Incremental analysis.
- Grouping columns and Statistics columns. See Grouped analysis.
Warning
In PuppyGraph 1.21.0 and earlier, saving with no grouping column, or clicking Retry analysis afterwards, also removes the statistics of the whole table. Queries that read the table run without them until the new analyze finishes.
Click Save and analyze to save the settings and analyze the table. Changing analyze settings requires DATA:write when role-based access control is enabled.
The settings are stored in the Iceberg catalog's tableSettings, so you can also set them in the schema:
"tableSettings": [
{
"schema": "retail",
"table": "orders",
"analyze": {
"groupingColumns": ["store_id"],
"statisticsColumns": ["is_refunded"]
}
},
{
"schema": "retail",
"table": "events",
"analyze": { "mode": "INCREMENTAL" }
}
]
mode is FULL, INCREMENTAL, or left out for the deployment default.

