Segments
Part VII
Temporary Segments Oracle has tons of Info on Metalink read and use that as you evolve Oracle
over a period evolved the temporary segments and their usage. Evolution
is from permanent tablespace with temporary contents to temporary tablespace
with tempfile to temporary tabelspace groups. Most importantly all these
evolutionary phases are still available depending upon choices.
The evolution of the tablespace TEMPORARY started with 7.3 and this tablespace TEMPORARY is created using datafile/s. The evolution of the TEMPORARY Tablespace started with 8i and this TEMPORARY Tablespace is created with tempfile/s. You identify a tablespace TEMPORARY/TEMPORARY tablespace in DBA_TABLESPACES for its CONTENTS of TEMPORARY type Purpose of these Temporary segments A
tablespace TEMPORARY/TEMPORARY tablespace provides a single temporary
segment shared by all users requiring This unique temporary segment improves the concurrence of multiple sort operations, multiple transactions on the same temporary table using the same temporary segment, reduces their overhead, and avoids Oracle space management operations altogether. These temporary segments are created after the instance is started (Oracle sits idle before the instance is started when you connect) and as soon as user/s starts a sort operation or when a temporary extent is required for the GLOBAL TEMPORARY table. This temporary segment is dropped when instance is shutdown. The following synonyms can be accessed to view the allocation and de-allocation activity of these temporary segments 01.
V$SORT_SEGMENT Please read Metalink Doc Id 102339.1 to understand more about the temporary segments usage and the benefits of using the TEMPORARY tablespace with tempfile/s The following activities require the temporary segments: 01.
Creation index Memory Usage is dependent on the server configurations. Sorting requires space in memory. These memory areas are called sort areas. Every user session has its own sort area size. The "init.ora" SORT_AREA_SIZE parameter defines the maximum size of real memory (in bytes) that will be used by a single sort. Common settings of the SORT_AREA_SIZE parameter range between 64K and 256K for larger systems. The location in memory where this sort area is allocated depends on the configuration of the Server. In the DEDICATED SERVER CONFIGURATION the sort area is allocated in the Program Global Area (PGA). Besides this sort area, the PGA also contains session- information (e.g. user-privileges), cursor-status (of that session) and stack-space (session-variables). In the Multi-threaded Server Configuration the sort area is allocated in the User Global Area (UGA). This UGA lies in the Shared Pool of the System Global Area (SGA). Space Management is dependent on the way the tablespace is configured. Dictionary-Managed
Tablespace (DMT) For a tablespace that uses the data dictionary to manage its extents Oracle updates the appropriate tables in the data dictionary whenever an extent is allocated or freed for reuse. A tablespace that uses the data dictionary to manage its extents has by default incremental extent sizes, which are determined by the storage parameters INITIAL, NEXT, and PCTINCREASE. When an object is created in the tablespace, its first extent is allocated with the INITIAL size. When additional space is needed, the NEXT and PCTINCREASE parameters determine the sizes of new extents. Because dictionary tables are part of the database, the space that they occupy is subject to the same space management operations as all other data. This is the default method of space management in a tablespace. It was the only method available in Oracle releases 8.0 and earlier. Locally
Managed Tablespace (LMT) A tablespace that manages its own extents maintains a bitmap in each datafile to keep track of the free or used status of blocks in that datafile. Each bit in the bitmap corresponds to a block or a group of blocks. When an extent is allocated or freed for reuse, Oracle changes the bitmap values to show the new status of the blocks. A tablespace that manages its extents locally can have either uniform extent sizes or variable extent sizes that are determined automatically by the system. When you create the tablespace, the UNIFORM or AUTOALLOCATE (system-managed) option specifies the type of allocation. The storage parameters NEXT, PCTINCREASE, MINEXTENTS, MAXEXTENTS, and DEFAULT STORAGE are not valid parameters for extents that are managed locally. When a TEMPORARY tablespace is created the formatting is different to datafile. The tempfile created is called sparse file. A sparse file is a file where any 'empty' O/S blocks do not actually take up a full block but have a marker to show the block is empty. The operating system then finds a free block for use when the block is populated with data. An Oracle8 data file is filled with formatted blocks when it is created, but the middle of these blocks contains all ‘0’s, which may span one or more O/S blocks. An Oracle8i TEMPFILE is NOT explicitly filled with '0's and can be created as a sparse file on some platforms. This is correct behavior for this type of TEMPFILE Advantages of LMT 01.
Reduces recursive calls to the Metadata Note: Disadvantages of DMT 01.
Tablespace can have more than one temp segment and the creation of these
segments is based on the transactions. Who takes care de-allocation in LMT? The background process SMON actually de-allocates the sort segment after the instance has been started and the database has been opened. Thus, after the database has been opened, SMON may be seen to consume large amounts of CPU as it first de-allocates the (extents from the) temporary segment, and after that performs free space coalescing of the free extents created by the temporary segment cleanup. This behavior will be exaggerated if the temporary tablespace, in which the sort segment resides, has inappropriate (small) default NEXT storage parameters. Down side of it? This means that Oracle 9i onwards if you are using LM TEPORARY tablespace in your database you are to plan the reboot schedule basing on the usage of the temporary tablespace and the max space allocated for the temporary tablespaces. Note If your SYSTEM tablespace is created as LMT you cannot have any dictionary-managed tablespace of any nature. Guidelines as Prescribed By Oracle in Creating and Managing Temporary Segments: 01.
Use LMT temporary tablespaces to avoid frequent allocation, de-allocation
segments and thus fragmentation of tablespace/s
|