Bug #104040 | Update histogram with json data | ||
---|---|---|---|
Submitted: | 16 Jun 2021 13:26 | Modified: | 28 Jun 2022 10:10 |
Reporter: | Kaiwang CHen (OCA) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S4 (Feature request) |
Version: | 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[16 Jun 2021 13:26]
Kaiwang CHen
[17 Jun 2021 6:24]
MySQL Verification Team
Hello Kaiwang, Thank you for the feature request! regards, Umesh
[21 Sep 2021 1:33]
casa zhang
Hi, This is really an useful feature. Besides offload of histogram gathering tasks, it helps tools to migrate optimization context between servers. I have a patch for it. Note that this patch depends on that of Bug#104108 to be stable on tests, so it is also included from reference.
[21 Sep 2021 1:37]
casa zhang
ANALYZE TABLE UPDATE HISTOGRAM USING DATA (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: 0001-Bug-104040-ANALYZE-TABLE-UPDATE-HISTOGRAM-USING-DATA.patch (application/octet-stream, text), 230.51 KiB.
[28 Jun 2022 10:10]
Jon Stephens
Fixed in MySQL 8.0.31 as part of WL#15123. See same for docs info. Closed.
[20 Jul 2022 15:30]
Frederic Descamps
Thank you for your contribution ! As you could read this has been included in MySQL 8.0.31. Cheers
[12 Oct 2022 15:10]
Jon Stephens
Documented fix as follows in the MySQL 8.0.31 changelog: It is now possible to set a column histogram to a user-specified JSON value. This can be useful when sampling leaves out important values. This also means that a secondary (replica) MySQL server can assume the work of sampling the data and building the histogram, which can then be used on the primary (source) without impacting its performance. This capability is provided through an extension to ANALYZE TABLE ... UPDATE HISTOGRAM. The following statement sets the histogram for column col_name of table tbl_name to the histogram's JSON representation json_data: ANALYZE TABLE tbl_name UPDATE HISTOGRAM ON col_name USING DATA 'json_data' You can confirm afterwards this by checking the value of the HISTOGRAM column of the Information Schema COLUMN_STATISTICS table. See Histogram Statistics Analysis, for more information and examples. Our thanks to Kaiwen Chen for this contribution to MySQL. Also updated "ANALYZE TABLE Syntax" in the 8.0 Manual. (Already closed.)