Problem/Motivation The flagging table can be slow to access for particularly large datasets.
Proposed resolution Create a StorageSchema handler to change the row format of the flagging table and add an index to be equivalent to the following SQL.
ALTER TABLE `flagging` ROW_FORMAT = DYNAMIC
ALTER TABLE `flagging` ADD INDEX `flag_id__uid__session_id` ( `flag_id` , `uid` , `session_id` )
Remaining tasks
Create patch.
User interface changes None.
API changes None.
Data model changes None.
Original issue
We're using the getUserFlagFlagginCount method on the flag.count service. We've got a massive flagging table of +300.000 rows and the method is running massively slow. We've been able to fix this by creating a new table index:
ALTER TABLE `flagging` ROW_FORMAT = DYNAMIC
ALTER TABLE `flagging` ADD INDEX `flag_id__uid__session_id` ( `flag_id` , `uid` , `session_id` )
This gave us a massive database performance boost. I've not been able to create a patch for this as we speak, though I just made this into a issue for documentation and patching purposes.