Automatically create tables for long queries