twfb: Try to reuse prepare database statements as much as possible

This gave a ~2.4x speed increase in queries benchmark.