Debian 9 (Stretch) install MariaDB 10.1 from it's repository. Its possible to install latest version of MariaDB on Debian 9 to get good database performance. Here is the method to install MariaDB 10.4 on Debian 9 when preparing system for Koha installation. This method can apply for a fresh installation of Koha. Don't try on existing installation of Koha.
Install dirmngr
sudo apt-get install software-properties-common dirmngr
Importing the MariaDB GPG Public Key and install MariaDB
Apply following commands,
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirrors.accretive-networks.net/mariadb/repo/10.4/debian stretch main'
sudo apt update
sudo apt-get install mariadb-server
Assign Root password for MySQL
Apply following command,
sudo mysqladmin -u root password newpass [Replace 'newpass' with new password]
References
https://mariadb.com/kb/en/library/installing-mariadb-deb-files/#importing-the-mariadb-gpg-public-key
https://downloads.mariadb.org/mariadb/repositories/#distro=Debian&distro_release=stretch--stretch&mirror=rise&version=10.4