We want to migrate a LAMP server from MySQL 5.7 to MariaDB 10.6. We cloned the server, installed MariaDB and migrated the database. I was expecting some speed improvements with SQL queries, but my surprise is that our app is slower with the MariaDB. I'm trying to analyze some queries, I expose you a specific case.
We've a VIEW that we use in many other queries, something like this:
ALTER ALGORITHM = MERGE DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `GT_VWCalendariProfessionalInc` AS
SELECT cpInc.prof, cpInc.start_date, cpInc.end_date
FROM GT_CalendariProfessional cpInc
JOIN CTR_Motius ON cpInc.colA = CTR_Motius.colA
WHERE cpInc.necessitat IS NULL AND ...
Key indexes in cpInc table: ix_necessitat (column necessitat), ix_professional (column prof), ix_outerjoin_nec_dates (columns necessitat, start_date, end_date)
Using this view from external query with MySQL is faster than with MariaDB. The query is like this:
SELECT kal.prof, kal.start_date, kal.end_date
FROM GT_CalendariProfessional kal
LEFT JOIN GT_VWCalendariProfessionalInc AS cpInc ON cpInc.prof = kal.prof AND kal.start_date < cpInc.end_date AND cpInc.start_date < kal.end_date
WHERE kal.prof=3143 AND kal.start_date BETWEEN '2021-01-01 00:00' AND '2022-01-01 00:00'
With EXPLAIN I see that MariaDB is using an inefficient index (ix_professional). I can't FORCE INDEX inside the view because we use the view in other queries with different execution plans, and an index inefficient here can be the best in other queries.
Execution plan with MySQL (Fast):

Execution plan with MariaDB (Slow):

In general, many queries with MariaDB are slower than with MySQL