Try something like this ``` CREATE TRIGGER log_trig BEFORE INSERT ON LOG WHEN exists( SELECT 1 FROM LOG WHERE col1 = new.col1 AND col2 = new.col2 AND dt >= datetime(new.dt, '-10 seconds') ) BEGIN raise(abort, 'Log too soon'); END; ``` An index on col1, col2, dt should work with that just fine... I think.