zoukankan      html  css  js  c++  java
  • [bbk4998] 第104集 第13章 表空间管理 02

    BitMap信息是保存在段头信息.

    录入信息的时候,就是直接读取段头信息,不在读取数据字典中的信息;

    以前使用数据字典方式进行管理的时候,当多用户多并发的操作发生时,就会发生高负荷的读写系统表空间的操作,增加系统负荷.因为数据字典的信息是存放在系统表空间当中的.

    段就是存储各种类型数据的对象,段的空间分配是通过extent来实现的.

    oracle采用延迟创建段技术,提高效率;当一个表创建的时候,不给它创建对应的段空间信息,只有在使用的时候才创建;

    没有段信息的索引或者分区索引是不可用的.

    在10g以前的版本中,将索引置为不可用的时候,其所占用的空间依然是存在的;在10g,11g之后,删除了或者设为不可用之后,其所占的空间会释放.

    ALTER INDEX test_i UNUSABLE;设置索引不可用,同时释放所占资源空间.如果想恢复索引,则直接rebuild即可.

    Free Space Management Within Segments

    • Tracked by bitmaps in segments
    • Benefits:
    • More flexible space utilization
    • Run-time adjustment
    • Multiple process search of BMBs

    Types of Segments

    A segment is a set of extents allocated for a certain logical structure.The different types of segments include:

    • Table and cluster segments
    • Index segment
    • Undo segment
    • Temporary segment

    Segments are dynamically allocated by the Oracle database server.

    Segments的四大类型

    Allocating Extents

    • Searching the data file`s bitmap for the required number of adjacent free blocks
    • Sizing extents with storage clauses:
      • -UNIFORM
      • -AUTOALLOCATE
    • View extent map
    • Obtaining deallocation advice
      • 通过查看extent map之后,可以适当进行deallocation advice操作

    Allocating Space

    New space allocation method:

    SQL> show parameter deferr
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    deferred_segment_creation            boolean     TRUE
    1. Table creation > Data dictionary operation
    2. DML > Segment creation

    使用延迟创建segment信息的益处:

    • Saving disk space
    • Improving installation time of big applications

    Creating Tables without segments

    SQL> show parameter deferr
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    deferred_segment_creation            boolean     TRUE
    SQL> conn test/test
    Connected.
    
    SQL> create table seg_test(c number,d varchar2(500));
    
    Table created.
    
    SQL> select segment_name from user_segments;
    
    SEGMENT_NAME
    --------------------------------------------------------------------------------
    EMP1
    EMP_EMPLOYEE_ID_IDX
    
    SQL> insert into seg_test values(1,'abcdefg');
    
    1 row created.
    
    SQL> select segment_name from user_segments;
    
    SEGMENT_NAME
    --------------------------------------------------------------------------------
    EMP1
    SEG_TEST
    EMP_EMPLOYEE_ID_IDX

    上面示例说明,在创建新表的时候,未插入新的数据之前,是没有分配段信息的.

    Controlling Deferred Segment Creation

    With the DEFERRED_SEGMENT_CREATION parameter in the:

    • Initialization file
    • ALTER SESSION command
    • ALTER SYSTEM command

    With the SEGMENT CREATION clause

    • IMMEDIATE
    • DEFERRED(default in Oracle Database 11gR2)

    CREATE TABLE SEG_TAB3(C1 number,C2 number) SEGMENT CREATION IMMEDIATE TABLESPACE SEG_TBS;

    CREATE TABLE SEG_TAB4(C1 number,C2 number) SEGMENT CREATION DEFERRED;

    Note:Indexes inherit table characteristics.

    Restrictions and Exceptions

    Segment creation on demand:

    • Only for nonpartitioned tables and indexes
    • Not for IOTs,clustered tables,or other special tables
    • Not for tables in dictionary-managed tablespaces

    Note:If you were to migrate a table without segments from a locally managed to a dictionary-managed tablespace,you must drop and re-create it.

    Additional Automatic Functionality

    without user intervention:

    • No segments for unusable indexes and index partitions
    • Creating an index without a segment
    CREATE INDEX test_i1 ON seg_test(c) UNUSABLE;
    • Removing any allocated space for an index:
    ALTER INDEX test_i UNUSABLE;
    • Creating the segment for an index:
    ALTER INDEX test_i REBUILD;
    SELECT segment_name,partition_name,segment_type
    
    FROM user_segments
    
    WHERE segment_name like '%DEMO%';
  • 相关阅读:
    Python学习札记(十五) 高级特性1 切片
    LeetCode Longest Substring Without Repeating Characters
    Python学习札记(十四) Function4 递归函数 & Hanoi Tower
    single number和变体
    tusen 刷题
    实验室网站
    leetcode 76. Minimum Window Substring
    leetcode 4. Median of Two Sorted Arrays
    leetcode 200. Number of Islands 、694 Number of Distinct Islands 、695. Max Area of Island 、130. Surrounded Regions 、434. Number of Islands II(lintcode) 并查集 、178. Graph Valid Tree(lintcode)
    刷题注意事项
  • 原文地址:https://www.cnblogs.com/arcer/p/3126974.html
Copyright © 2011-2022 走看看