• 段指导-示例


    RDBMS 19.20

    参考文档:

    Database Administrator’s Guide
    19 Managing Space for Schema Objects
    19.3.2.4 Running the Segment Advisor Manually

    针对表SOE.CUSTOMERS进行段指导
     

    -- 创建段指导

    1. variable id number;
    2. begin
    3. declare
    4. name varchar2(100);
    5. descr varchar2(500);
    6. obj_id number;
    7. begin
    8. name:='Manual_Employees';
    9. descr:='Segment Advisor Example';
    10. dbms_advisor.create_task (
    11. advisor_name => 'Segment Advisor',
    12. task_id => :id,
    13. task_name => name,
    14. task_desc => descr);
    15. dbms_advisor.create_object (
    16. task_name => name,
    17. object_type => 'TABLE',
    18. attr1 => 'SOE',
    19. attr2 => 'CUSTOMERS',
    20. attr3 => NULL,
    21. attr4 => NULL,
    22. attr5 => NULL,
    23. object_id => obj_id);
    24. dbms_advisor.set_task_parameter(
    25. task_name => name,
    26. parameter => 'recommend_all',
    27. value => 'TRUE');
    28. dbms_advisor.execute_task(name);
    29. end;
    30. end;
    31. /

    -- 查看段指导是否运行完毕

    1. select task_name, status
    2. from dba_advisor_tasks
    3. where task_name = 'Manual_Employees'
    4. and advisor_name = 'Segment Advisor';

    -- 查看段指导对应的结果

    1. select af.task_name, ao.attr2 segname, ao.attr3 partition, ao.type, af.message
    2. from dba_advisor_findings af, dba_advisor_objects ao
    3. where ao.task_id = af.task_id
    4. and ao.object_id = af.object_id
    5. and af.task_name = 'Manual_Employees'
    6. select task_name,message,more_info from dba_advisor_findings where task_name = 'Manual_Employees'
    7. --select * from DBA_ADVISOR_RECOMMENDATIONS where task_name = 'Manual_Employees'
    8. --select * from DBA_ADVISOR_ACTIONS where task_name = 'Manual_Employees'
    9. select task_name,command,attr1,attr2,attr3 from DBA_ADVISOR_ACTIONS where task_name like '%SYS_AUTO_SPCADV%'
    10. select * from DBA_ADVISOR_OBJECTS where task_name = 'Manual_Employees'

    -- 查看近期的段指导建议

    1. select tablespace_name,
    2. segment_name,
    3. segment_type,
    4. partition_name,
    5. recommendations,
    6. c1
    7. from table(dbms_space.asa_recommendations('FALSE', 'FALSE', 'FALSE'));

    --部分结果示例

    1. SYS@test>select task_name,message,more_info from dba_advisor_findings where task_name = 'Manual_Employees'
    2. 2 ;
    3. TASK_NAME
    4. --------------------------------------------------------------------------------
    5. MESSAGE
    6. --------------------------------------------------------------------------------
    7. MORE_INFO
    8. --------------------------------------------------------------------------------
    9. Manual_Employees
    10. The free space in the object is less than 10MB.
    11. Allocated Space:180355072: Used Space:178803055: Reclaimable Space :1552017:
    12. SYS@test>
    1. SYS@test>select task_name,command,attr1,attr2,attr3 from DBA_ADVISOR_ACTIONS where task_name like '%SYS_AUTO_SPCADV%';
    2. TASK_NAME
    3. --------------------------------------------------------------------------------
    4. COMMAND
    5. ----------------------------------------------------------------
    6. ATTR1
    7. --------------------------------------------------------------------------------
    8. ATTR2
    9. --------------------------------------------------------------------------------
    10. ATTR3
    11. --------------------------------------------------------------------------------
    12. SYS_AUTO_SPCADV126200902092023
    13. SHRINK SPACE
    14. alter table "OGG"."GGS_DDL_HIST" shrink space
    15. TASK_NAME
    16. --------------------------------------------------------------------------------
    17. COMMAND
    18. ----------------------------------------------------------------
    19. ATTR1
    20. --------------------------------------------------------------------------------
    21. ATTR2
    22. --------------------------------------------------------------------------------
    23. ATTR3
    24. --------------------------------------------------------------------------------
    25. alter table "OGG"."GGS_DDL_HIST" shrink space COMPACT
    26. alter table "OGG"."GGS_DDL_HIST" enable row movement
    27. TASK_NAME
    28. --------------------------------------------------------------------------------
    29. COMMAND
    30. ----------------------------------------------------------------
    31. ATTR1
    32. --------------------------------------------------------------------------------
    33. ATTR2
    34. --------------------------------------------------------------------------------
    35. ATTR3
    36. --------------------------------------------------------------------------------
    37. SYS_AUTO_SPCADV126200902092023
    38. ENABLE COMPRESSION
    39. alter table "SOE"."ORDERS" compress for oltp
    40. TASK_NAME
    41. --------------------------------------------------------------------------------
    42. COMMAND
    43. ----------------------------------------------------------------
    44. ATTR1
    45. --------------------------------------------------------------------------------
    46. ATTR2
    47. --------------------------------------------------------------------------------
    48. ATTR3
    49. --------------------------------------------------------------------------------
    50. alter table "SOE"."ORDERS" move
    51. TASK_NAME
    52. --------------------------------------------------------------------------------
    53. COMMAND
    54. ----------------------------------------------------------------
    55. ATTR1
    56. --------------------------------------------------------------------------------
    57. ATTR2
    58. --------------------------------------------------------------------------------
    59. ATTR3
    60. --------------------------------------------------------------------------------
    61. SYS_AUTO_SPCADV126200902092023
    62. ENABLE COMPRESSION
    63. alter table "SOE"."CUSTOMERS" compress for oltp
    64. TASK_NAME
    65. --------------------------------------------------------------------------------
    66. COMMAND
    67. ----------------------------------------------------------------
    68. ATTR1
    69. --------------------------------------------------------------------------------
    70. ATTR2
    71. --------------------------------------------------------------------------------
    72. ATTR3
    73. --------------------------------------------------------------------------------
    74. alter table "SOE"."CUSTOMERS" move
    75. TASK_NAME
    76. --------------------------------------------------------------------------------
    77. COMMAND
    78. ----------------------------------------------------------------
    79. ATTR1
    80. --------------------------------------------------------------------------------
    81. ATTR2
    82. --------------------------------------------------------------------------------
    83. ATTR3
    84. --------------------------------------------------------------------------------
    85. SYS_AUTO_SPCADV126200902092023
    86. ENABLE COMPRESSION
    87. alter table "OGG"."GGS_DDL_HIST" compress for oltp
    88. TASK_NAME
    89. --------------------------------------------------------------------------------
    90. COMMAND
    91. ----------------------------------------------------------------
    92. ATTR1
    93. --------------------------------------------------------------------------------
    94. ATTR2
    95. --------------------------------------------------------------------------------
    96. ATTR3
    97. --------------------------------------------------------------------------------
    98. alter table "OGG"."GGS_DDL_HIST" move
    99. TASK_NAME
    100. --------------------------------------------------------------------------------
    101. COMMAND
    102. ----------------------------------------------------------------
    103. ATTR1
    104. --------------------------------------------------------------------------------
    105. ATTR2
    106. --------------------------------------------------------------------------------
    107. ATTR3
    108. --------------------------------------------------------------------------------
    109. SYS_AUTO_SPCADV258251302092023
    110. SHRINK SPACE
    111. alter table "OGG"."GGS_DDL_HIST" shrink space
    112. TASK_NAME
    113. --------------------------------------------------------------------------------
    114. COMMAND
    115. ----------------------------------------------------------------
    116. ATTR1
    117. --------------------------------------------------------------------------------
    118. ATTR2
    119. --------------------------------------------------------------------------------
    120. ATTR3
    121. --------------------------------------------------------------------------------
    122. alter table "OGG"."GGS_DDL_HIST" shrink space COMPACT
    123. alter table "OGG"."GGS_DDL_HIST" enable row movement
    124. TASK_NAME
    125. --------------------------------------------------------------------------------
    126. COMMAND
    127. ----------------------------------------------------------------
    128. ATTR1
    129. --------------------------------------------------------------------------------
    130. ATTR2
    131. --------------------------------------------------------------------------------
    132. ATTR3
    133. --------------------------------------------------------------------------------
    134. SYS_AUTO_SPCADV616480909092023
    135. SHRINK SPACE
    136. alter table "OGG"."GGS_DDL_HIST" shrink space
    137. TASK_NAME
    138. --------------------------------------------------------------------------------
    139. COMMAND
    140. ----------------------------------------------------------------
    141. ATTR1
    142. --------------------------------------------------------------------------------
    143. ATTR2
    144. --------------------------------------------------------------------------------
    145. ATTR3
    146. --------------------------------------------------------------------------------
    147. alter table "OGG"."GGS_DDL_HIST" shrink space COMPACT
    148. alter table "OGG"."GGS_DDL_HIST" enable row movement
    149. TASK_NAME
    150. --------------------------------------------------------------------------------
    151. COMMAND
    152. ----------------------------------------------------------------
    153. ATTR1
    154. --------------------------------------------------------------------------------
    155. ATTR2
    156. --------------------------------------------------------------------------------
    157. ATTR3
    158. --------------------------------------------------------------------------------
    159. SYS_AUTO_SPCADV705541309092023
    160. SHRINK SPACE
    161. alter table "OGG"."GGS_DDL_HIST" shrink space
    162. TASK_NAME
    163. --------------------------------------------------------------------------------
    164. COMMAND
    165. ----------------------------------------------------------------
    166. ATTR1
    167. --------------------------------------------------------------------------------
    168. ATTR2
    169. --------------------------------------------------------------------------------
    170. ATTR3
    171. --------------------------------------------------------------------------------
    172. alter table "OGG"."GGS_DDL_HIST" shrink space COMPACT
    173. alter table "OGG"."GGS_DDL_HIST" enable row movement
    174. TASK_NAME
    175. --------------------------------------------------------------------------------
    176. COMMAND
    177. ----------------------------------------------------------------
    178. ATTR1
    179. --------------------------------------------------------------------------------
    180. ATTR2
    181. --------------------------------------------------------------------------------
    182. ATTR3
    183. --------------------------------------------------------------------------------
    184. SYS_AUTO_SPCADV705541309092023
    185. ENABLE COMPRESSION
    186. alter table "OGG"."GGS_DDL_HIST" compress for oltp
    187. TASK_NAME
    188. --------------------------------------------------------------------------------
    189. COMMAND
    190. ----------------------------------------------------------------
    191. ATTR1
    192. --------------------------------------------------------------------------------
    193. ATTR2
    194. --------------------------------------------------------------------------------
    195. ATTR3
    196. --------------------------------------------------------------------------------
    197. alter table "OGG"."GGS_DDL_HIST" move
    198. 8 rows selected.
    199. SYS@test>

    END

  • 相关阅读:
    设计LRU/LFU缓存结构
    【Java面试】面试自閟了!工作5年的小伙伴今天面试被吊打问我,并行和并发有什么区别?
    文心一言 VS CHATGPT
    【Linux-day11-线程的创建与同步】
    万字长文详解HBase读写性能优化
    springboot+rediss实现分布式定时任务
    【pandas数据分析】pandas功能和操作简单示例
    202311.13 windows通过vscode ssh远程连接到Ubuntu 连接失败 waiting for server log
    网络传输 Tips 小记
    掌握系统性思维
  • 原文地址:https://blog.csdn.net/xxzhaobb/article/details/132850986