简体   繁体   中英

Oracle Temp table segment size - select query inconsistent

I have been using Oracle for a year now and come across a new problem with tablespace TEMP - my terminology may be lacking here. How do I modify TEMP table segment size so my select queries run successfully all the time.

I have a select statement that will work at one point in time but then it will fail at other times. Is it possible that the TEMP table segment size in Oracle somehow changes which can affect whether or not a given select statement will work at one time but fail at another time? The reason is b/c I have ran a select statement that will run successfully one time but will fail the next time. When it fails it gives this error:

ORA-01652: unable to extend temp segment by 64 in tablespace TEMP

Also is this TEMP table segment size specific to a single user or processes session? Or is it related to the global memory of all processes?

My goal here is to try and find the problem and maybe see if its a memory problem or TEMP table problem that can be easily fixed.

Also I'm interested if someone else is running a large query at the same time and maybe this causes the problem or exasperates the problem by reducing the ability of the TEMP table to be extended additional segments.

TEMP space is allocated at the instance level and is shared by all users. If your query uses a large fraction of the TEMP space that is available for the instance, it is certainly possible that it could fail intermittently depending on how much space other users happen to be consuming at that instant in time. If some other user has a runaway query that consumes all the available TEMP space, it is also possible that you would get an error even if your query is a relatively light consumer of TEMP space though it would be odd for that to happen often enough for you ask the question.

Assuming that your query is using a relatively large fraction of the available TEMP space, I would wager that it is probably in need of some serious optimization. I've seen my share of queries that do things like inadvertently generate a Cartesian product and then do a DISTINCT on that to get down to the correct result set. That obviously requires far more TEMP space than writing the correct join at the outset. It's also possible that the statistics on one or more object is causing Oracle to expect that some step is going to return a very small number of rows when it really returns a large number which is causing the optimizer to pick a plan that uses far more TEMP than it expected. If your query can be optimized to use less TEMP space, that is generally the easiest fix.

If your query is fully optimized but still consumes a large fraction of the TEMP space allocated to the instance, then you'd want to have a conversation with your DBA. It is possible that the DBA has underallocated TEMP space for the system and can just throw a few more GB into TEMP will fix your problems (as well as everyone else that is getting the same error).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM