diff --git a/extra/mariadb/0007-MDEV-20646.patch b/extra/mariadb/0007-MDEV-20646.patch new file mode 100644 index 000000000..53ca497e9 --- /dev/null +++ b/extra/mariadb/0007-MDEV-20646.patch @@ -0,0 +1,45 @@ +commit d4edb0510ec1189f65850bb47977e94ed98b1f71 +Author: Sergei Petrunia +Date: Wed Nov 13 18:53:59 2019 +0300 + + MDEV-20646: 10.3.18 is slower than 10.3.17 + + Fix incorrect change introduced in the fix for MDEV-20109. + + The patch tried to compute a more precise estimate for the record_count + value in SJ-Materialization-Scan strategy (in + Sj_materialization_picker::check_qep). However the new formula is worse + as it produces extremely optimistic results in common cases where + SJ-Materialization-Scan should be used) + + The old formula produces pessimistic results in cases when Sj-Materialization- + Scan is unlikely to be a good choice anyway. So, the old behavior is better. + +diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc +index aeafc13998a..a8afd952a4d 100644 +--- a/sql/opt_subselect.cc ++++ b/sql/opt_subselect.cc +@@ -3029,7 +3029,22 @@ bool Sj_materialization_picker::check_qep(JOIN *join, + + *strategy= SJ_OPT_MATERIALIZE_SCAN; + *read_time= prefix_cost; +- *record_count= prefix_rec_count / mat_info->rows_with_duplicates; ++ /* ++ Note: the next line means we did not remove the subquery's fanout from ++ *record_count. It needs to be removed, as the join prefix is ++ ++ ntX SJM-SCAN(it1 ... itN) | (ot1 ... otN) ... ++ ++ here, the SJM-SCAN may have introduced subquery's fanout (duplicate rows, ++ rows that don't have matches in ot1_i). All this fanout is gone after ++ table otN (or earlier) but taking it into account is hard. ++ ++ Some consolation here is that SJM-Scan strategy is applicable when the ++ subquery is smaller than tables otX. If the subquery has large cardinality, ++ we can greatly overestimate *record_count here, but it doesn't matter as ++ SJ-Materialization-Lookup is a better strategy anyway. ++ */ ++ *record_count= prefix_rec_count; + *handled_fanout= mat_nest->sj_inner_tables; + return TRUE; + } diff --git a/extra/mariadb/PKGBUILD b/extra/mariadb/PKGBUILD index b3383ff06..b7bff56a3 100644 --- a/extra/mariadb/PKGBUILD +++ b/extra/mariadb/PKGBUILD @@ -9,23 +9,29 @@ pkgbase=mariadb pkgname=('mariadb-libs' 'mariadb-clients' 'mariadb' 'mytop') pkgdesc='Fast SQL database server, derived from MySQL' pkgver=10.4.10 -pkgrel=1 +pkgrel=2 arch=('x86_64') license=('GPL') url='https://mariadb.org/' makedepends=('boost' 'bzip2' 'cmake' 'jemalloc' 'libaio' 'libxml2' 'lz4' 'lzo' 'openssl' 'systemd' 'zlib' 'zstd') validpgpkeys=('199369E5404BD5FC7D2FE43BCBCB082A1BB943DB') # MariaDB Package Signing Key -source=("https://downloads.mariadb.org/interstitial/mariadb-${pkgver}/source/mariadb-${pkgver}.tar.gz"{,.asc} +# The default links with mirror redirection fail for signatures, specific +# mirrors may be out of date every now and then. Let's use the upstream +# rsync source and hope it does not hurt them too much. +# https://mariadb.com/kb/en/library/mirror-sites-for-mariadb/ +source=("rsync://rsync.osuosl.org/mariadb/mariadb-${pkgver}/source/mariadb-${pkgver}.tar.gz"{,.asc} '0001-arch-specific.patch' '0002-systemd-sysusers-tmpfiles.patch' '0005-fix-galera_recovery-with-fs.protected_regular-enabled.patch' + '0007-MDEV-20646.patch' '0001-libatomic.patch') sha256sums=('cd50fddf86c2a47405737e342f78ebd40d5716f0fb32b976245de713bed01421' 'SKIP' 'ce72ea1563ad773e00e8b1c299babea176abae1102827c2f743921e9de615041' '3e83467af80fbd53400a201a34fc858b88509ea8e88b10709947eb66545f9457' 'c8c801f80924ccb97b499552fe1c532b3ebf8f86cdfc0d23715d4adb1a8810f0' + '825d4ab1601c9e97bf24857bcfd8bed2b6d8ad15a4c2411c7867bff2333b09d8' '1c7360453b6e964c6546cbbb10fff697f6227554eba716b2a1df74f7c2613d95') prepare() { @@ -47,6 +53,9 @@ prepare() { # https://github.com/MariaDB/server/pull/1137 patch -Np1 < ../0005-fix-galera_recovery-with-fs.protected_regular-enabled.patch + # MDEV-20646: 10.3.18 is slower than 10.3.17 + patch -Np1 < ../0007-MDEV-20646.patch + if [[ $CARCH == arm || $CARCH == armv6h ]]; then patch -p1 -i ../0001-libatomic.patch fi