DB queries can be expensive. It would be cool if cargo had configuration options to limit risk around expensive queries.
The options available (Note, these may differ between mariadb and mysql):
- MAX_EXECUTION_TIME - MediaWiki already has support for this as an item in the $options array. It kills queries that take too long. I think it might make sense to have a default of 90 seconds (this option is in ms), and have a config option for users who want to be more paranoid. Queries taking longer than 90 seconds probably aren't likely to work that well anyways due to php max execution time.
- max_join_size - will prevent running queries that mariadb thinks will look at a lot of rows (mariadb could be wrong of course). This has the benefit of not even starting the query if it looks like it would be bad. That said I don't know how accurate it really is.
- LIMIT .. ROWS EXAMINED - if you have an SQL statement like LIMIT XXX ROWS EXAMINED 10000000; The sql query will stop after looking at 10000000 rows. It will possibly give partial results with a warning if that happens, or it might give an error. I think this is similar to max_join_size except that instead of guessing before the query begins, it runs the query until it hits the limit. This is different than the normal LIMIT since it is rows looked at not rows returned. (I think this is mariadb only and not supported by mysql. Unfortunately the MW abstraction layer doesn't support this afaik)
Anyways, i think it would be useful to have these as config options in Cargo. Especially the MAX_EXECUTION_TIME one, which might make sense to be on by default with a high limit.