I recently read somewhere that one of ways of tuning SQL query is that if it has too many joins, then do one join with fewer tables and cache the results in a temporary table, then do the rest of the query joining on that table.
My question is how it will improve the performance, as you are joining same numbers of tables (only not together)?
Note: I agree this is generic statement; I read it recently in some article. I will rephrase it. Under which conditions will storing a result into temp table help?
One of the reasons that you invest in a product like Oracle is for the development work they put in the optimizer piece of their engine. It has constantly improved over 20+ years, and in general, with proper statistics for your tables and indexes, it is hard to correctly outguess it for access to your data.
If I interpret your question as how would performance improve in queries of real-time data by building temporary tables each time the query executes, I would say that it wouldn’t in most cases. In those other cases, instead of building a temporary table invest the time in structuring the query with Oracle’s relatively new WITH clause which will handle materializing subsets of data dynamically in those cases where it makes sense to the optimizer.
If your question is about denormalizing data in a materialized view, data mart, or data warehouse fashion then yes this can dramatically improve query performance at the expense of access to the current state of the information (since the denormalized tables are always out of date). This improvement comes about in general because the RDBMS engine has less physical access work to do for the query because you have already done it once to build the denormalized structures.