[5.x][MariaDB] add Field::getValueSql Event / support virtual columns / how to increase query performance #13997
-
We usually use MariaDB (not my decision) and the upcoming Craft 5 content changes will cause heavy performance issues for some projects unless we do things we really should not do (eg: create a regex over SQL / overwrite all fields / overwrite the ElementQuery class) since MariaDB does not allow to create indexes in JSON as easily. (please correct me if I'm wrong - nothing worked for me, in case there is a way I'll be happy) To deal with this, we tried to create virtual columns and include an index on these ALTER TABLE `elements_sites` ADD `my_custom_index` TEXT AS (cast(json_extract(`content`,'$.\"0f071920-8bce-4807-8065-a6962a55f577\"') as TEXT)) VIRTUAL; This allows us to keep a higher performance, however all field Queries must now create their The ultimate solution would be a config file that could map fields with their indexed column so we could add indexes on the fly without the requirement to sync project configs. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 11 replies
-
MariaDB support is going to be deprecated in Craft 5. There have been numerous performance and stability issues with it, and its lack of proper JSON support was the last straw. We’ve worked around the JSON limitation just to ensure Craft still works with Maria, but I don’t see us going this extra step, when you would be better off switching to MySQL which fully supports JSON and functional indexes. |
Beta Was this translation helpful? Give feedback.
-
Given this (somewhat surprising) info, what are the steps to take an existing project that's in Maria (because that's been the default "MySQL" in most distro's for many years now) and port it to Oracle's MySQL? I'm kinda surprised MySQL is still being considered the "main database" to develop against, and not Maria, tbh. Given the overall ecosystem. Are we able to Craft database export from a Maria install, remove Maria from the server, install "real MySQL", and safely import? |
Beta Was this translation helpful? Give feedback.
MariaDB support is going to be deprecated in Craft 5. There have been numerous performance and stability issues with it, and its lack of proper JSON support was the last straw.
We’ve worked around the JSON limitation just to ensure Craft still works with Maria, but I don’t see us going this extra step, when you would be better off switching to MySQL which fully supports JSON and functional indexes.