SlideShare a Scribd company logo
1 of 7
Oracle Table or Index
Compress Note
Create Table As Select
   create table aa_comp compress as select *
    from aa; 的壓縮比率會比較高,以
    AC1FIL_DAY 為例 壓縮前 376M 壓縮後
    104M 約 27%
                       原始 TABLE
                        500MB



                      壓縮後新 TABLE
      原始 TABLE          135MB
        1G


                         釋放出
                         365MB
Index Build
   如果具有 index 的 table 須先將 index
    drop , alter table aa move compress
    ; 以 AC1FIL_DAY 為例 壓縮前 376M 壓
    縮後 103M 約 27% , 且需重新建立
    index
    且 index 再重新建立時也可以設定
    compress ,但是 PK 與 BITMAP index
    不行設定為 compress
Insert Into Use Append
   Table 建立時設定為 compress ,在資料
    要塞入時移掉要用 append 的方式塞入
   insert /*+ APPEND*/ into
    AC1FIL_DAY_COMP select * from
    AC1FIL_DAY;
   壓縮比率較高,以 AC1FIL_DAY 為例 壓
    縮前 376M 壓縮後 104M 約 27%
Compress MATERIALIZED VIEW
   ALTER MATERIALIZED VIEW
    LMCM_JCIC_QUERYH move compress;
   ALTER INDEX
    ODS_TB_LMB.PKCM_JCIC_QUERYH
    REBUILD COMPRESS ;
   EXECUTE dbms_mview.refresh
    ('LMCM_JCIC_QUERYH');
   壓縮前 240M 壓縮後 96M 約 40% , 且需重新
    建立 index ,但是該 TABLE 有較多的 CHAR 與
    DATE 的欄位
Compress Table Partition
   alter table LOAN_HIST MOVE partition
    SP_LOAN_HIST_201001 tablespace
    DM_CIB_S_01 compress nologging;
   壓縮前 28499M 壓縮後 21652M 約
    75% ,但是該 Partition 為 1 月的資料壓
    縮後所釋放的結果, LOAN_HIST 裡面尚
    有 2 月 3 月 4 月的資料,所以估計可壓縮
    為 20%
注意事項
   TABLE 內 CHAR 與 DATE 欄位過多則壓縮比會比較低
   Compress 過後的 TABLE , Index 需要 Rebuild
   若 UPDATE 壓縮過的 TABLE 效能會降低
   Oracle compresses some data types including
      VARCHAR2
      NUMBER
      RAW
   Oracle does not compress
      DATE
      CHAR

More Related Content

Featured

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Oracle table or index compress note

  • 1. Oracle Table or Index Compress Note
  • 2. Create Table As Select  create table aa_comp compress as select * from aa; 的壓縮比率會比較高,以 AC1FIL_DAY 為例 壓縮前 376M 壓縮後 104M 約 27% 原始 TABLE 500MB 壓縮後新 TABLE 原始 TABLE 135MB 1G 釋放出 365MB
  • 3. Index Build  如果具有 index 的 table 須先將 index drop , alter table aa move compress ; 以 AC1FIL_DAY 為例 壓縮前 376M 壓 縮後 103M 約 27% , 且需重新建立 index  且 index 再重新建立時也可以設定 compress ,但是 PK 與 BITMAP index 不行設定為 compress
  • 4. Insert Into Use Append  Table 建立時設定為 compress ,在資料 要塞入時移掉要用 append 的方式塞入  insert /*+ APPEND*/ into AC1FIL_DAY_COMP select * from AC1FIL_DAY;  壓縮比率較高,以 AC1FIL_DAY 為例 壓 縮前 376M 壓縮後 104M 約 27%
  • 5. Compress MATERIALIZED VIEW  ALTER MATERIALIZED VIEW LMCM_JCIC_QUERYH move compress;  ALTER INDEX ODS_TB_LMB.PKCM_JCIC_QUERYH REBUILD COMPRESS ;  EXECUTE dbms_mview.refresh ('LMCM_JCIC_QUERYH');  壓縮前 240M 壓縮後 96M 約 40% , 且需重新 建立 index ,但是該 TABLE 有較多的 CHAR 與 DATE 的欄位
  • 6. Compress Table Partition  alter table LOAN_HIST MOVE partition SP_LOAN_HIST_201001 tablespace DM_CIB_S_01 compress nologging;  壓縮前 28499M 壓縮後 21652M 約 75% ,但是該 Partition 為 1 月的資料壓 縮後所釋放的結果, LOAN_HIST 裡面尚 有 2 月 3 月 4 月的資料,所以估計可壓縮 為 20%
  • 7. 注意事項  TABLE 內 CHAR 與 DATE 欄位過多則壓縮比會比較低  Compress 過後的 TABLE , Index 需要 Rebuild  若 UPDATE 壓縮過的 TABLE 效能會降低  Oracle compresses some data types including  VARCHAR2  NUMBER  RAW  Oracle does not compress  DATE  CHAR