How to speed up slow Magento indexer process? Maria DB 10.4

Reindexing on MariaDB 10.4 takes more time compared to other MariaDB or MySQL versions. As a workaround, we suggest modifying the default MariaDB configuration and setting the following parameters:

optimizer_switch='rowid_filter=off'
optimizer_use_condition_selectivity = 1

After these changes, restart your database. In aws, RDS automatically updates these parameters without any downtime or requirement for restarting. You will see noticeable difference in indexer time.

Refer Link:
https://mariadb.com/kb/en/rowid-filtering-optimization/
https://devdocs.magento.com/guides/v2.4/performance-best-practices/configuration.html
https://devdocs.magento.com/guides/v2.4/extension-dev-guide/indexer-batch.html