Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document table statistics support in MySQL connector #17632

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions presto-docs/src/main/sphinx/connector/mysql.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,57 @@ Finally, you can access the ``clicks`` table in the ``web`` database::
If you used a different name for your catalog properties file, use
that catalog name instead of ``mysql`` in the above examples.

Performance
-----------

The connector includes a number of performance improvements, detailed in the
following sections.

.. _mysql-table-statistics:

Table statistics
^^^^^^^^^^^^^^^^

The MySQL connector can use :doc:`table and column statistics
</optimizer/statistics>` for :doc:`cost based optimizations
</optimizer/cost-based-optimizations>`, to improve query processing performance
based on the actual data in the data source.

The statistics are collected by MySQL and retrieved by the connector.

The table-level statistics are based on MySQL's ``INFORMATION_SCHEMA.TABLES``
table. The column-level statistics are based on MySQL's index statistics
``INFORMATION_SCHEMA.STATISTICS`` table. The connector can return column-level
statistics only when the column is the first column in some index.

MySQL database can automatically update its table and index statistics. In some
cases, you may want to force statistics update, for example after creating new
index, or after changing data in the table. You can do that by executing the
following statement in MySQL Database.

.. code-block:: text

ANALYZE TABLE table_name;

.. note::

MySQL and Presto may use statistics information in different ways. For this
reason, the accuracy of table and column statistics returned by the MySQL
connector might be lower than than that of others connectors.

**Improving statistics accuracy**

You can improve statistics accuracy with histogram statistics (available since
MySQL 8.0). To create histogram statistics execute the following statement in
MySQL Database.

.. code-block:: text

ANALYZE TABLE table_name UPDATE HISTOGRAM ON column_name1, column_name2, ...;

Refer to MySQL documentation for information about options, limitations
and additional considerations.

MySQL Connector Limitations
---------------------------

Expand Down