Skip to main content
CREATE ANALYZE customizes an automatic collection task for collecting CBO statistics. By default, the database automatically collects full statistics of a table. It checks for any data updates every 5 minutes. If data change is detected, data collection will be automatically triggered. If you do not want to use automatic full collection, you can set the FE configuration item enable_collect_full_statistic to false and customize a collection task. Behaviour difference:
  • Before 3.2.12 and 3.3.4, to create a custom automatic collection task, you must disable automatic full collection (enable_collect_full_statistic = false). Otherwise, custom tasks cannot take effect.
  • Since these version, you can create analyze job and keep system tasks. The user-created tasks would overwrite the system tasks if they have conflicts.
This statement is supported from v2.4.

Syntax

Parameter description

  • Collection type
    • FULL: indicates full collection.
    • SAMPLE: indicates sampled collection.
    • If no collection type is specified, sampled collection is used by default.
  • col_name: columns from which to collect statistics. Separate multiple columns with commas (,). If this parameter is not specified, the entire table is collected.
  • PROPERTIES: custom parameters. If PROPERTIES is not specified, the default settings in fe.conf are used. The properties that are actually used can be viewed via the Properties column in the output of SHOW ANALYZE JOB.

Examples

Example 1: Automatic full collection
Example 2: Automatic sampled collection

References

SHOW ANALYZE JOB: view the status of a custom collection task. DROP ANALYZE: delete a custom collection task. KILL ANALYZE: cancel a custom collection task that is running. For more information about collecting statistics for CBO, see Gather statistics for CBO.