Skip to main content

BUILD STATS

Builds statistics on the table for query optimization. For examples, see Examples.

bSQL Syntax Conventions

Syntax​

BUILD STATS|STATISTICS ON { blockchain_name | database_name.blockchain_name }

Arguments​

database_name
Is the name of the database to build stats on.

blockchain_name
The name of the blockchain that you would like to build stats on.

Permissions​

MANAGEMENT permission required on the target blockchain.

MANAGEMENT permissions default to members of the admin and developer fixed database roles. Members of the admin role can transfer permissions to other users.

Best Practices​

Building stats creates a more accurate heuristic for internal optimizations. It is important to have accurate statistics when computing the costs of complex queries typically used for analytics and reporting. Please refer to stats overview for a more detailed explanation on how statistics are built for performance.

Limitations​

  • Currently, statistics can't be built on a blockchain that has no stats and, the command will error. This means the blockchain stats were either dropped using the DROP STATS command, or the blockchain was built using the WITHOUT STATS keyword in a CREATE BLOCKCHAIN statement.

Examples ​

Building statistics on a blockchain.​

The following example builds stats on the pricing blockchain in the demo database, after the command has run the query optimizer will have more accurate statistics on pricing.

BUILD STATS ON financial.pricing

See Also​