MERGEBLOCKRATIO - Analytics Database - Teradata Vantage

SQL Data Definition Language Detailed Topics

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
vuk1628111288877.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
jbg1472252759029
lifecycle
latest
Product Category
Teradata Vantage™

The MERGEBLOCKRATIO option provides a way to combine existing small data blocks into a single larger data block during full table modification operations for permanent tables and permanent journal tables. This option is not available for volatile and global temporary tables. The file system uses the merge block ratio that you specify to reduce the number of data blocks within a table that would otherwise consist mainly of small data blocks. Reducing the number of small data blocks enables Vantage to reduce the I/O overhead of operations that must read and modify a large percentage of the table. It is not possible to define a general block size that would be considered to be small in this context. The exact block size that fits this description is somewhat subjective and can differ based on the I/O performance that occurs at different sites.

For tables that are frequently modified by inserting new data, the average block size varies between 50% and 100% of their maximum supported multirow block size. This maximum supported size is defined as either the table-level attribute DATABLOCKSIZE (see CREATE TABLE) or the system-level block size for the table as defined in the DBS Control record if you have not established a value for the DATABLOCKSIZE attribute for a table.

Note that when you delete rows from a table, the blocks that previously held the deleted rows can become smaller than the sizes in the defined range, and their new sizes can vary considerably from your user-defined block size.

An extreme example of a block size distribution that benefits from having its data blocks merged together is a table whose blocks were created with an average size of 64 KB, but which have gradually shrunk or split over time to an average size of only 8 KB. This example is extreme because it is uncommon for requests to access every data block in a table. If block splits were common for this table, its number of data blocks can have increased by an order of magnitude.

If the rows in the table could be repackaged into blocks whose size were closer to the original average block size, you would probably experience improved response times for queries that read most or all of the blocks in the table because the number of logical or physical reads (or both) would then be reduced by an order of magnitude as well.

Merging blocks automatically augments the existing functionality of the ALTER TABLE statement DATABLOCKSIZE option, with or without the IMMEDIATE option. Although this option lessens the problem of tables with small blocks, there are drawbacks:
  • Resolving the small data blocks problem requires a DBA to manually execute new SQL requests.
  • You must also determine which tables and block sizes are causing performance problems before you can submit the SQL requests necessary to resolve the problem. For example, table data block size statistics are available using the SHOWBLOCKS command of the Ferret utility or the equivalent SQL interface using the CreateFsysInfoTable and PopulateFsysInfoTable macros. For information on the Ferret utility, see Teradata Vantage™ - Database Utilities, B035-1102. For information on the CreateFsysInfoTable and PopulateFsysInfoTable macros, see Teradata Vantage™ - SQL Operators and User-Defined Functions, B035-1210.
  • The operations performed by the problem resolving SQL request require an EXCLUSIVE table-level lock, which then blocks concurrent update activity on the table.
  • If you specify the IMMEDIATE option, some data blocks in the table may become smaller as soon as the table is updated. If you do not specify the IMMEDIATE option, some data blocks in the table might take a long time to grow larger again if they are not updated for some time. See IMMEDIATE DATABLOCKSIZE.
The merge block ratio approach does not have these drawbacks and offers the following enhanced functionality:
  • Runs automatically without DBA intervention.
  • Does not require the analysis of block size histograms.
  • Does not require any specific AMP-level locking.
  • Continuously searches for small data blocks to merge together even when some of those blocks are not being updated.

For more information about performance-related aspects of the MERGEBLOCKRATIO option, see Performance Aspects of Merging Data Blocks.

The size threshold at which small data blocks are merged can be controlled either using the MERGEBLOCKRATIO option or by changing the setting of the MergeBlockRatio DBS Control flag. It is also possible to deactivate the merging of small data blocks by changing the setting of the DisableMergeBlocks field of the DBS Control record. For more information, see Teradata Vantage™ - Database Utilities, B035-1102.