https://devhubby.com/thread/how-to-optimize-the-mariadb-query