A strange problem was found during the test yesterday: During the query module of the Program , the start speed is very fast, but after a while, the speed will slow down. In the end, an error will be reported and it will not work. In the troubleshooting process, we found that the temporary tablespace in Oracle has soared to dozens of gigabytes. We tracked the session in Oracle and found that the disk space is still being consumed, almost every 5 s, the temporary tablespace will increase by about mb. The final error should be caused by the absence of disk space allocation. This is a terrible thing.
we know that the temporary Oracle tablespace is mainly used to query and store cache data. One of the main reasons for disk consumption is to sort the query results, if no error is found, Oracle uses greedy algorithm in the allocation of disk space (memory, if the consumption of the last disk space reaches 1 GB, the temporary tablespace is 1 GB. If there is still growth, the temporary tablespace remains at the maximum. The analysis of the terrorism phenomenon mentioned above may be caused by the following reasons.
1. The limit is not set for the temporary tablespace, but is allowed to increase infinitely. However, if you set an upper limit, you may still encounter an error due to insufficient space. The temporary tablespace setting is too small, which affects performance. The temporary tablespace setting is too large, which also affects performance, as for how many cases need to be set, you need to perform a careful test.
2. When you query a table, too many tables are used in the join Table query. We know that during a table connection query, A discar product is generated based on the queried fields and the number of tables. The size of the discar product is the size of the temporary space required for a query, if too many fields are queried and the data is too large, a large temporary tablespace is consumed.
3. Some fields in the query are not indexed. In Oracle, if the table does not have an index, all the data will be copied to the temporary tablespace. If there is an index, the data of the index is generally copied to the temporary tablespace.
Based on the above analysis, the query statements and indexes are optimized to alleviate the problem, but further tests are required.
conclusion:
1. SQL statements may affect disk consumption. Improper statements may cause disk spikes.
2. You need to carefully plan the query statements. do not define a query statement, especially in software that provides custom queries.
3. Carefully plan table indexes.
if you have encountered a similar problem, please give your suggestions.