Using a switch instead of if/else is faster though I don't know that you could do it with your code. Also, it's not appreciably faster in this context.
If you want to know exactly what in your code is causing the lag, you need to instrument it. In other words, do something like this around statements that you think could be causing a problem:
Code:
new start = seconds();
// one or more statements
log_to_file("_test", "blahblah took %i seconds", seconds() - start);
Doing this will tell you where you need to optimize the code. My guess is that the
dbi_query line is causing your problems thus my suggestion to use SQLx.
__________________