Methods and implementation of distributed ing compatibility in DB2

Source: Internet
Author: User
Database Version compatibility is an important issue. From DB2V9.7, the distribution buing (distributionmap) has been extended from 4096 entries to 32768 entries, how can we achieve compatibility between high and low versions of distribution ing?

Database Version compatibility is a very important issue. From DB2 V9.7 onwards, the distribution tion ing (distribution map) has been extended from 4096 entries to 32768 entries, how can we achieve compatibility between high and low versions of distribution ing?

This article introduces and implements a method to extend a copy of the distributed ing array to the same size as that of the higher version and contain 32768 entries in the lower version of DB2, after processing, you can perform the same processing on different versions, such as calling the APIs for data distribution.

When developing the DB2 program, the compatibility of earlier versions is one of the important issues that we have to consider. You must hope that the programs you write will support all versions of DB2, at least some commonly used DB2 versions, such as v9.7 and v9.5.

When you use the APIS provided by DB2 to compile the application database partition function program, you will often use the distribution ing (distribution map ), developers can use the distribution ing array as a parameter and call the corresponding API to distribute data to the corresponding database partition. For V9.7 and later versions, this API is db2GetRowPartNum, which explicitly states that the distribution ing in the parameter must be an array containing SQL _PDB_MAP_SIZE_32K (32768) entries when calling this API. Now the problem arises. The distribution ing of the DB2 database V9.5 and earlier only contains SQL _pdb_map_size_4 K (4096) Entries. We need to support both versions V9.5 and V9.7. How should we implement data distribution?

Maybe we can treat V9.5 and V9.7 differently. When the connected database is V9.5, call the sqlugrpn API that is not recommended since V9.7 and input 4 K route distribution ing arrays, one prerequisite for successful distribution is to set the registration variable DB2_PMAP_COMPATIBILITY to ON before calling this API. When DB2 is V9.7, call db2GetRowPartNum and input 32 K distribution ing arrays.

This is of course a method, but the specific parameters of the two APIs are different, so that the implementation of this program becomes complicated; you also need to determine the DB2 version and handle it separately.

Another solution to this version compatibility problem is to extend the distribution ing copy from 4 K entries to 32 K entries when we encounter a lower version of DB2. We know that each database partition in the distribution ing has a certain cycle pattern. After finding this pattern, it can be fully expanded correctly.

The following describes the repetition rules of each database partition in the distribution ing and how to extend the distribution ing array through code.

Note: This article only discusses the IBMDEFAULTGROUP database partition groups created in databases with multiple database partitions. The methods and structures used by the implementation programs described in this article, and APIs are based on V9.7. This article does not discuss the storage order of bytes of different machines, that is, it is considered to be the same.

Brief Introduction to distribution ing

In a multi-database partition Data Partition group, the distribution ing contains multiple database partitions, and each database partition is repeated in the distribution ing. If a database is created on four database partitions, the number of database partitions ranges from 0 to 3, then the distribution ing of the IBMDEFAULTGROUP database partition group of this database is (taking the distribution ing containing 32 K entries as an example ):

Figure 1. Distribution ing containing 32 K entries

Distribution ing that contains 32 K entries. It can be seen that the distribution ing from database partition 0 to database partition 3 is repeated. When the DB2 version is V9.7 or later, the distribution ing copy obtained by calling the db2GetDistMap API is shown in the table containing 32 K entries; when the DB2 version is V9.5 or earlier, the distribution ing copy obtained by calling the sqlugtpi API contains only the first 4 K entries.

It is worth noting that the "boundary value" of the distribution ing"

We often use four database partitions numbered 0 to 3 to illustrate the database partition function or distribution ing. In this case, there are 4,096th "boundary values, 8,192nd and 16,384th entries are database partitions numbered 0. However, each database partition repeats cyclically in the distribution ing of 32 K entries or in the distribution ing of 4 K entries, and then recyclically repeats every 4 K entries in the distribution ing of the entire 32 K entries?

In other words, what is the distribution ing of 32 K entries and the "Boundary Value" if there are odd numbers, such as three database partitions?

Connect to a database of V9.7 or later and call the db2GetDistMap API. The distribution ing copy is shown in:

Figure 2. Distribution ing of database partition groups composed of three database partitions

It can be seen that all the database partitions do not repeat the distribution ing in a circular order, because if so, the blue entries should follow the order of the previous entries, the database partition number is 1 rather than 0. In fact, the distribution ing of 32 K entries starts a new cycle for every 4 K entries, and each database partition in the 4 K entries repeats in a loop.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.