presto-docs/src/main/sphinx/optimizer/statistics.rst
Presto supports statistics based optimizations for queries. For a query to take advantage of these optimizations, Presto must have statistical information for the tables in that query.
Table statistics are provided to the query planner by connectors. Implementing support for table statistics is optional. The decision is left to the authors of the connector.
Statistics are exposed to the query planner by a table layout. A table layout represents a subset of a table's data and contains information about the organizational properties of that data (like sort order and bucketing).
The number of table layouts available for a table and the details of those table layouts are specific to each connector. Using the Hive connector as an example:
The following statistics are available in Presto:
For a table:
For each column in a table:
The set of statistics available for a particular query depends on the connector being used and can also vary by table or even by table layout. For example, the Hive connector does not currently provide statistics on data size or histograms, while the Iceberg connector provides both.
Table statistics can be fetched using the :doc:/sql/show-stats query.
For the Hive connector, refer to the :ref:Hive connector <hive_analyze>
documentation to learn how to update table statistics.