How to improve the query efficiency of MariaDB

recently, after the company migrated sql server to mariadb, data, it found that the query efficiency was much lower.

there are now multiple data tables, each with more than 10w rows of data, and the data in the table is not unique and the index cannot be used.

with the most common LEFT JOIN,sql server, it takes a few seconds to get a result, while mariadb takes hundreds of seconds.

how should mariadb optimize configuration and query? Baidu has no suitable answer.

this is the query result of mariadb
clipboard.png

sql server
clipboard.png

this is a query statement. The number is not unique and the index cannot be used.

SELECT a.*, b.* FROM  a, b WHERE a.type = "up" AND b.type = "up" AND a.number = b.number 

Mar.20,2021

No matter whether it is unique or not, it is indexed. Anyway, mysql has all kinds of keys and indexes, so just add a common index directly. In addition, even if there is no index, the data should not be so slow.


EXPLAIN SQL
explain SELECT a.forth, b. * FROM a, b WHERE a.type = 'up' AND b.type =' up' AND a.number = b.number;
execute to take a look at the result.
this sentence SQL is essentially JOIN
it is recommended to write:

SELECT * from a left join (select * from b where b.type='up') c on a.number = c.number where a.type='up'
Menu