Hi! My recent project had some specific requirements regarding the work with database. Since DB server had some limitations (regarding number of queries), and fairly big number of queries that needed to be executed I created a solution that included temp tables. And now, I’d like to explain how to use them and why.
Suppose that in your application, you need to execute a calculation on a set of tables. The usual approach is to create a query that defines the joins between multiple tables, and selects the data from the joined tables. The problem with that approach is that every time you call that the query, the tables have to be rejoined in order to create the result. And that is usually fairly resource hungry. Instead, you can get around the problem by putting the results into temporary table, so the values are there while the database connection lasts.