Bug #100966 | select count(*) works very slow for uncommitted data | ||
---|---|---|---|
Submitted: | 27 Sep 2020 3:46 | Modified: | 16 Nov 2020 15:35 |
Reporter: | Brian Yue (OCA) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S2 (Serious) |
Version: | MySQL8.0.18, 8.0.21 | OS: | Any (rhel-7.4) |
Assigned to: | CPU Architecture: | Any (intel x86) | |
Tags: | contributions |
[27 Sep 2020 3:46]
Brian Yue
[27 Sep 2020 5:56]
Brian Yue
By the way, considering that buffer pool may affect the result, I have changed it as a very very small value.
[28 Sep 2020 11:30]
Brian Yue
some problem with previous implementation, latest like this: @@ -535,10 +535,22 @@ dberr_t Parallel_reader::Ctx::traverse() { } const rec_t *rec = page_cur_get_rec(cur); offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); + /* bug fix: compare with visible record may leads to many times waste of io recource, + because we may miss endpoint due to invisibility. + so, we use latest version of data to compare end point instead. */ + if (rec != nullptr && end_tuple != nullptr) { + auto ret = end_tuple->compare(rec, index, offsets); + + /* Note: The range creation doesn't use MVCC. Therefore it's possible + that the range boundary entry could have been deleted. */ + if (ret <= 0) { + break; + } + } + auto skip = !m_scan_ctx->check_visibility(rec, offsets, heap, &mtr);
[10 Oct 2020 6:26]
MySQL Verification Team
Hello Brian Yue, Thank you for the report and supplying patch. Please note that in order to submit contributions you must first sign the Oracle Contribution Agreement (OCA). More details are described in "Contributions" tab, please ensure to re-send the patch via that tab. Otherwise we would not be able to accept it. regards, Umesh
[17 Oct 2020 14:19]
Brian Yue
basing on MySQL version 8.0.18 (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: bug100966_patch.txt (text/plain), 865 bytes.
[18 Oct 2020 5:44]
MySQL Verification Team
Thank you for the contribution. regards, Umesh
[16 Nov 2020 15:35]
Daniel Price
Posted by developer: Fixed as of the upcoming 8.0.23 release, and here's the proposed changelog entry from the documentation team: A SELECT COUNT(*) operation on a table containing uncommitted data performed poorly due to unnecessary I/O. Thanks to Brian Yue for the contribution.