473,608 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Table Partition Performance analysis

16 New Member
Table Partition Performance analysis
=============== =============== ==============

Collection of Statistics for Cost-Based Optimization/DBMS_STATS vs. ANALYZE

The cost-based approach relies on statistics and if the cost-based
Approach is used , then statistics should be gernerated for all tables, clusters, and all types of indexes accessed by SQL statements. If the size and data distribution of your tables change frequently, then generate statistics regularly to ensure the statistics accurately represent the data in the tables.

Select * from test partition;
This uses global statistics but no predicate
select * from test s where s.amount_of_shi ft > 1000;
This uses a predicate for more than one partition and may use global statistics
select * from test partition (sep2009) s where s.amount_of_shi ft > 1000;
This uses global statistics and predicate to one partition.

Gathering global statistics with the DBMS_STATS package is more useful because ANALYZE always runs serially. DBMS_STATS can run in serial or parallel. Whenever possible, DBMS_STATS calls a parallel query to gather statistics with the specified degree of parallelism; otherwise, it calls a serial query or the ANALYZE statement. Index statistics are not gathered in parallel.

ANALYZE gathers statistics for the individual partitions and then calculates the global statistics from the partition statistics. DBMS_STATS can gather separate statistics for each partition as well as global statistics for the entire table or index. Depending on the SQL statement being optimized, the optimizer may choose to use either the partition (or subpartition) statistics or the global statistics.

Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE PARTTAB(
  2.     ordid        NUMBER,
  3.     PARTCOL    DATE,        
  4.     DETAILS     NUMBER,
  5.     AMOUNT    NUMBER)
  6. PARTITION BY RANGE(PARTCOL)
  7. SUBPARTITION BY HASH(DETAILS) SUBPARTITIONS 2 
  8. (PARTITION q1 VALUES LESS THAN(TO_DATE('01-04-2009','DD-MM-YYYY')) TABLESPACE TBLSPCE1,
  9.  PARTITION q2 VALUES LESS THAN(TO_DATE('01-07-2009','DD-MM-YYYY')) TABLESPACE TBLSPCE2,
  10.  PARTITION q3 VALUES LESS THAN(TO_DATE('01-10-2009','DD-MM-YYYY')) TABLESPACE TBLSPCE3,
  11.  PARTITION q4 VALUES LESS THAN(TO_DATE('01-12-2009','DD-MM-YYYY')) TABLESPACE TBLSPCE4
  12. );
  13.  
  14. A local non prefixed index will be associated with it:
  15.  
  16. CREATE INDEX IDX_PARTTAB ON PARTTAB (ordid) LOCAL;
  17.  
  18. The PARTTAB table has been populated before to start the following examples.
  19.  
  20.  
  21.  
  22.  GATHER_TABLE_STATS
  23. -------------------
  24.  
  25.  Collects table, column, and index statistics.
  26.  
  27. Compute, serial mode, without histograms, Default granularity.
  28. ============================================================
  29.  
  30. SQL> execute dbms_stats.gather_table_stats(-
  31. >ownname => 'test',-
  32. >tabname => 'PARTTAB',-
  33. >partname => null,-                --> Gather stats on all partitions.
  34. >estimate_percent => null,-        --> Compute mode
  35. >block_sample => false,-            --> Default value. No Sense in Compute mode
  36. >method_opt => 'FOR ALL COLUMNS SIZE 1',-    --> Table and columns statistics. No histogram generated
  37. >degree => null,-                --> default parallel degree based on DOP set on PARTTAB.
  38. >granularity => 'default',-        --> Gather Global and Partition statistics
  39. >cascade => true ,-                --> with index stats generated
  40. >stattab => null,-                --> The statistics will be stored in the dictionary.
  41. >statid => null,-
  42. >statown => null);
  43.  
  44. PL/SQL procedure successfully completed.
  45.  
  46.  
  47.  Index Statistics won't be calculated by default if  CASCADE=>TRUE .
  48.  
  49.  
  50. SQL> select table_name, NUM_ROWS, BLOCKS, EMPTY_BLOCKS, AVG_SPACE, AVG_ROW_LEN
  51.     , GLOBAL_STATS, USER_STATS, sample_size from user_tables
  52.     where table_name = 'PARTTAB';
  53.  
  54. TABLE_NAME NUM_ROWS BLOCKS EMPTY_BLOCKS AVG_SPACE AVG_ROW_LEN GLOBAL_STATS USER_STATS SAMPLE_SIZE
  55. ---------- -------- ------ ------------ --------- ----------- ------------ ---------- -----------
  56. PARTTAB          400      8            0         0          11 YES          NO                 400
  57.  
  58. Now that the statistics have been updated. 
  59. The column GLOBAL_STATS has been also initialized. 
  60.  
  61. SQL> select partition_name "Partition", NUM_ROWS, BLOCKS, EMPTY_BLOCKS, AVG_SPACE, AVG_ROW_LEN,
  62.  SAMPLE_SIZE, global_stats, user_stats
  63.  from user_tab_partitions
  64.  where table_name = 'PARTTAB'
  65.  order by partition_position
  66. /
  67.  
  68. Partition  NUM_ROWS BLOCKS EMPTY_BLOCKS  AVG_SPACE AVG_ROW_LEN GLOBAL_STATS USER_STATS SAMPLE_SIZE
  69. ---------- -------- ------ ------------ ---------- ----------- ------------ ---------- -----------
  70. Q1              100      2            0          0          11 YES          NO                 100
  71. Q2              100      2            0          0          11 YES          NO                 100
  72. Q3              100      2            0          0          11 YES          NO                 100
  73. Q4              100      2            0          0          11 YES          NO                 100
  74.  
  75.  
  76. The statistics are again obtained at the table level with the GLOBAL_STATS .
  77.  
  78.  
  79. SQL> select partition_name "Partition", subpartition_name "Subpartition", NUM_ROWS, BLOCKS, EMPTY_BLOCKS
  80.     SAMPLE_SIZE, global_stats, user_stats
  81.     from user_tab_subpartitions
  82.     where table_name = 'PARTTAB'
  83.     order by partition_name, subpartition_position
  84. /
  85.  
  86. Partition  Subpartition  NUM_ROWS BLOCKS EMPTY_BLOCKS AVG_SPACE AVG_ROW_LEN SAMPLE_SIZE GLOBAL_STATS USER_STATS
  87. ---------- ------------- -------- ------ ------------ --------- ----------- ----------- ------------ ----------
  88. Q1         SYS_SUBP10365                                                                          NO         NO
  89. Q1         SYS_SUBP10366                                                                          NO         NO
  90. Q2         SYS_SUBP10367                                                                          NO         NO
  91. Q2         SYS_SUBP10368                                                                          NO         NO
  92. Q3         SYS_SUBP10369                                                                          NO         NO
  93. Q3         SYS_SUBP10370                                                                          NO         NO
  94. Q4         SYS_SUBP10371                                                                          NO         NO
  95. Q4         SYS_SUBP10372                                                                          NO         NO
  96.  
  97. The statistics aren't computed at the subpartition level which is in phase 
  98. with the 'DEFAULT' granularity.
  99.  
  100.  
  101. SQL>select COLUMN_NAME, NUM_DISTINCT, DENSITY, NUM_NULLS, NUM_BUCKETS, LAST_ANALYZED from 
  102.  user_tab_col_statistics where table_name = 'PARTTAB'
  103. /
  104.  
  105. COLUMN_NAME     NUM_DISTINCT    DENSITY  NUM_NULLS NUM_BUCKETS LAST_ANALYZED
  106. --------------- ------------ ---------- ---------- ----------- -------------
  107. ORDID                      0          0        400           1 12-DEC-02
  108. PARTCOL                  4        .25          0           1 12-DEC-02
  109. DETAILS                100        .01          0           1 12-DEC-02
  110. AMOUNT                   0          0        400           1 12-DEC-02
  111.  
  112. The NUM_BUCKETS is set to 1 as there is no histogram generation. but, the column 
  113. statistics are well initialized
  114.  
  115. The same result is showed below on each partition columns:
  116.  
  117. SQL>select partition_name, COLUMN_NAME, NUM_DISTINCT, DENSITY, NUM_NULLS, NUM_BUCKETS, LAST_ANALYZED from user_part_col_statistics
  118.   where table_name = 'PARTTAB'
  119. /
  120.  
  121. PARTITION_ COLUMN_NAME     NUM_DISTINCT    DENSITY  NUM_NULLS NUM_BUCKETS LAST_ANALYZED
  122. ---------- --------------- ------------ ---------- ---------- ----------- -------------
  123. Q1         ORDID                      0          0        100           1 12-DEC-07
  124. Q1         PARTCOL                  1          1          0           1 12-DEC-07
  125. Q1         DETAILS                100        .01          0           1 12-DEC-07
  126. Q1         AMOUNT                   0          0        100           1 12-DEC-07
  127. Q2         ORDID                      0          0        100           1 12-DEC-07
  128. Q2         PARTCOL                  1          1          0           1 12-DEC-07
  129. Q2         DETAILS                100        .01          0           1 12-DEC-07
  130. Q2         AMOUNT                   0          0        100           1 12-DEC-07
  131. Q3         ORDID                      0          0        100           1 12-DEC-07
  132. Q3         PARTCOL                  1          1          0           1 12-DEC-07
  133. Q3         DETAILS                100        .01          0           1 12-DEC-07
  134. Q3         AMOUNT                   0          0        100           1 12-DEC-07
  135. Q4         ORDID                      0          0        100           1 12-DEC-07
  136. Q4         PARTCOL                  1          1          0           1 12-DEC-07
  137. Q4         DETAILS                100        .01          0           1 12-DEC-07
  138. Q4         AMOUNT                   0          0        100           1 12-DEC-07
  139.  
  140.  
  141. the statistics loaded for subpartitions of the PARTTAB table are displayed below:
  142.  
  143. SQL> select subpartition_name "Subpartition", COLUMN_NAME, NUM_DISTINCT, DENSITY, NUM_NULLS, 
  144.   NUM_BUCKETS from dba_subpart_col_statistics where table_name = 'PARTTAB'
  145.   order by column_name
  146. /
  147.  
  148. Subpartition    COLUMN_NAME     NUM_DISTINCT    DENSITY  NUM_NULLS NUM_BUCKETS
  149. --------------- --------------- ------------ ---------- ---------- -----------
  150. SYS_SUBP10365   PARTCOL
  151. SYS_SUBP10365   ORDID
  152. SYS_SUBP10365   DETAILS
  153. SYS_SUBP10365   AMOUNT
  154. SYS_SUBP10366   PARTCOL
  155. SYS_SUBP10366   ORDID
  156. SYS_SUBP10366   DETAILS
  157. SYS_SUBP10366   AMOUNT
  158. SYS_SUBP10367   PARTCOL
  159. SYS_SUBP10367   ORDID
  160. SYS_SUBP10367   DETAILS
  161. SYS_SUBP10367   AMOUNT
  162. SYS_SUBP10368   PARTCOL
  163. SYS_SUBP10368   ORDID
  164. SYS_SUBP10368   DETAILS
  165. SYS_SUBP10368   AMOUNT
  166. SYS_SUBP10369   PARTCOL
  167. SYS_SUBP10369   ORDID
  168. SYS_SUBP10369   DETAILS
  169. SYS_SUBP10369   AMOUNT
  170. SYS_SUBP10370   PARTCOL
  171. SYS_SUBP10370   ORDID
  172. SYS_SUBP10370   DETAILS
  173. SYS_SUBP10370   AMOUNT
  174. SYS_SUBP10371   PARTCOL
  175. SYS_SUBP10371   ORDID
  176. SYS_SUBP10371   DETAILS
  177. SYS_SUBP10371   AMOUNT
  178. SYS_SUBP10372   PARTCOL
  179. SYS_SUBP10372   ORDID
  180. SYS_SUBP10372   DETAILS
  181. SYS_SUBP10372   AMOUNT
No statistics were loaded on subpartition's columns.

Partitioned objects can contain more than one sets of statistics. This is because statistics can be generated for the entire object, partition, or subpartition.


Thanks & Regards,
Vinod Sadanandan
Oracle DBA
Dec 7 '07 #1
0 12962

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1796
by: Eric | last post by:
I'm trying to insert data for a real-time application that demands less than 3 second receipt-to-commit time, has a relatively large (500,000 records/hr) data rate, and requires access times on the order of 10-15 seconds. We're storing about 24 hours worth of data on a rolling basis, so I've partitioned the table by hour. Three of the columns are (separately) indexed. I know I can do this by piping data through sqlldr into the live...
1
1573
by: rick | last post by:
sql server 2000 I am currently maintaining a table that contains 30 Million+ records, 30 columns, and 11 indexes and will double within the next six mouths. The application that accesses this table, mainly for read only purposes, runs without any problems. We have begun using Crystal reports and are now having problems. When we create reports that accesses the large table our server has significant performance dip. The application...
10
9893
by: Bing Wu | last post by:
Hi Folks, I have a problem while creating a big table space. It reports error: SQL1139N The total size of the table space is too big Explanation: The size of the current table space is too big. The size of a REGULAR table space is limited to 0xFFFFFF (16777215) pages while the size of a TEMPORARY/LONG table space is limited to 2 tera bytes (2 TB). User Response: Check the diagnostic log file db2diag.log for details. Reduce the size...
1
2044
by: Mats Kling | last post by:
Hi all, We are logging approx. 3 million records every day into a history table. Last week we ran into the 64 GB limit in UDB 8 so we recreated the table with 8 k pagesize to get some breathingroom before we hit the 128 GB limit. We are considering partitioning and I just wanted to check with you that our proposal is the best one:
13
2653
by: James Conrad St.John Foreman | last post by:
One of the larger tables in our database is now 6.8 million rows (1 per financial transaction since 2000). Every time an amendment is made to a booking, new rows are added to the table for each transaction, so in general we never have any call to update old rows. Usually, we only deal with analysis on transactions in the current financial year or the previous one, but *occasionally* we'll want to go back further. So I'm thinking as...
1
5679
by: Mark Dengler | last post by:
I am trying to write a C# backend program that will handle the database maintenance that I would otherwise have to do via Microsoft's Analysis Services front end GUI Wizards. Currently I am having a problem with recreating the SliceValue. The value is a time dimension and should equate to ... and instead it is these same values, but instead of being seperated by periods it has some sort of non-displayable character (maybe a newline)...
4
3710
by: Hemant Shah | last post by:
Folks, Our client has a program that browses whole table from begining to end. The table has 1 million rows in it. REORGCHK does not show any problems. It has unique index defined on KEY0 column. If I use SELECT statement without OPTIMIZE FOR clause, then it uses temporary table to sort the data, but if I use OPTIMIZE clause then it uses index access without temporary table. If I use OPTIMIZE FOR more than 700 rows then it uses...
15
3669
by: Piero 'Giops' Giorgi | last post by:
Hi! I have a question: I already have a DB that uses partitions to divide data in US Counties, partitioned by state. Can I use TWO levels of partitioning? I mean... 3077 filegroups and 50 partition functions that address
0
1647
by: Damir | last post by:
Hello all! I created a range-partitioned table, and noticed that indexes were created as "NOT PARTITIONED" (through db2look), even though I ran the index creating commands without this parameter. Not that I care too much now about it :-) But what will happen when once upon a time in the future I execute the "attach partition" command, and so add another partition to the existing (partitioned) table. Will the indexes then be automatically...
0
8000
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8495
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8470
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4023
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1328
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.