Asagi:How to make Asagi insert faster

From 4plebs.Tech
Jump to: navigation, search

Large archives often have performance problems during Asagi post inserts. This is because Asagi has to update %%board%%_users and %%board%%_daily tables with statistics data. This statistics data is then used to create graphs and such in FoolFuuka board statistics plugin.

To make Asagi insert faster we can get rid of statistics procedures (or the calls to them).

For existing boards

  1. Stop your Asagi.
  2. Run this SQL on your Asagi database.
    It will remove the calls to statistics procedures. Replace %%board%% with your board short name.
DROP TRIGGER IF EXISTS "after_ins_%%board%%";
delimiter //
CREATE TRIGGER "after_ins_%%board%%" AFTER INSERT ON "%%board%%"
FOR EACH ROW
BEGIN
  IF NEW.op = 1 THEN
    CALL create_thread_%%board%%(NEW.num, NEW.timestamp);
  END IF;
  CALL update_thread_%%board%%(NEW.thread_num);
END//
DROP TRIGGER IF EXISTS "after_del_%%board%%"//
CREATE TRIGGER "after_del_%%board%%" AFTER DELETE ON "%%board%%"
FOR EACH ROW
BEGIN
  CALL update_thread_%%board%%(OLD.thread_num);
  IF OLD.op = 1 THEN
    CALL delete_thread_%%board%%(OLD.num);
  END IF;
  IF OLD.media_hash IS NOT NULL THEN
    CALL delete_image_%%board%%(OLD.media_id);
  END IF;
END//
delimiter ;
3. Start Asagi back up again.

For new boards

Use this branch of Asagi. New boards won't have statistics procedures.

But what about the statistics?

You can use this branch to make statistics plugin do the required work. Be advised that it's still rather untested, but it should work.