add query tracing, and create tables if they dont exist