Optimize trigger triggering query after synchronizing a table