Partitioning Techniques

You need to start planning for partitioning during the database analysis and design. In addition to dealing with the usual database analysis and design issues, you need to analyze every application and transaction with respect to the data that it accesses. Then you need to formulate an appropriate partitioning technique for each application.

There are three partitioning techniques that you can use in an OPS environment in order to reduce contention between instances:

Application partitioning

Aligns applications and nodes in a manner that avoids inter-nodal conflicts.

Data partitioning

Makes each node responsible for a different subset of the data within a table.

Transaction partitioning

Makes each node responsible for a different set of tables. Transactions are then routed to the most appropriate node by a transaction monitor or by the applications themselves.

Application Partitioning

Application partitioning is the process of separating database applications in such a way that each OPS node accesses a disjoint set of tables. Figure 11.2 shows two applications that are neatly partitioned between two nodes. Instance 1 runs the sales application, which has its own set of tables. Instance 2 runs the accounts application, which uses a different set of tables.

A neatly partitioned application

Figure 11-2. A neatly partitioned application

Tables used by multiple applications are referred to as overlap tables. There are no overlap tables in Figure 11.2. Each application is completely independent of the other. Because of this, the two instances will never contend for the same database block, and true pings will never occur.

Eliminating overlap tables from applications that are run from different OPS nodes is not sufficient to reduce or eliminate the occurrence of false pings. To reduce false pings, you must reduce the amount of PCM lock contention that occurs. A god way to do this is to place the tables and indexes used by each application in a separate tablespace and allocate separate PCM locks for the datafiles in each of those tablespaces. You want to ensure that the PCM locks protecting the data for one application are not also used to protect data used by another application. If one PCM lock covers data accessed from two different instances, you run the risk of false pings as a result of contention for that lock.

Tip

Even though OPS runs on a shared disk architecture, OPS performance is better when application partitioning makes the architecture function as if it’s a shared nothing architecture. In the scenario illustrated in Figure 11.2, for example, the instance on each node functions independently of the other—as if each node had its own disk, as would be the case with a shared nothing architecture.

Application partitioning must be performed when you first design the database and the applications that access it. If you don’t partition applications properly when you design them, your tuning of PCM lock allocation at later stages won’t be enough to reduce true pings. Tuning cannot substitute for proper application partitioning.

The process of application partitioning can be broken down into the following steps:

  1. Identify database applications.

  2. Identify overlap application tables.

  3. Identify operations on overlap tables.

  4. Configure tablespaces and deploy applications to nodes.

As an example, let’s consider three applications developed by the ABC Sales Company. One application is used by Product Sales clerks, another is used by Inventory clerks, and the third is used by Human Resource (HR) clerks. The Product Sales clerks of the ABC Sales Company use the Product Sales application to enter customer information into the database and to record sales transactions. Inventory clerks use the Inventory application to update the stock status and record the receipt of products from vendors. The HR clerks use the Human Resource application and are responsible for handling employee information, benefits, timesheets, and payroll. The company is planning to use a two-node OPS database to run these applications, and it’s your job to set up the database and applications to run as efficiently as possible. With that in mind, you can work through each of the four steps in the application partitioning process.

Identify database applications

The first step is to identify all applications that will run on the OPS database. Identify the various types and numbers of users who will run each application. Table 11.1 shows this information for our example of the ABC Sales Company.

Table 11-1. Database Applications and Database Users

Application

Users

Number of Users

Product Sales

Sales clerks

400

Inventory

Inventory clerks

100

Human resource

HR clerks

50

Identify overlap application tables

After identifying the applications, your next step is to identify the tables that will be accessed by each of those applications. Table 11.2 shows each of the tables accessed by the Product Sales, Inventory, and Human Resource applications, along with the type of table access (R=read, W=write, RW=read/write) by each application. Since this is a hypothetical example, we’ve shown only a few tables from each application. Using this information, you next will identify the tables that are used by two or more applications.

Table 11-2. Database Tables Used by the Product Sales, Inventory, and Human Resource Applications

Tables

Product Sales

Inventory

Human Resource

CUSTOMERS

RW

  

SALES

RW

  

SALES_DETAIL

RW

  

PRODUCTS

R

RW

 

STOCK

RW

RW

 

VENDORS

 

RW

 

RECEIPT

 

RW

 

EMPLOYEE

  

RW

BENEFITS

  

RW

APPRAISALS

  

RW

In our example, the PRODUCTS and STOCK tables are overlap tables. They are accessed by both the Product Sales application and the Inventory application. Figure 11.3 shows the overlap tables between Product Sales and Inventory applications.

Overlap tables

Figure 11-3. Overlap tables

Identify operations on overlap tables

Once you’ve identified the overlap tables, you can focus your attention on them. Tables that are used by only a single application do not cause true pings, unless you run that one application from multiple nodes. For the overlap tables, you need to perform a detailed analysis and determine both the type of data access and the volume of operations.

For each overlap table, identify the operation (INSERT, DELETE, UPDATE, or SELECT) performed by each application. In addition, estimate the daily volume of those operations. Let’s assume that the ABC Sales Company maintains a stock of 200,000 distinct products. Let’s further assume that in a one-hour period there are 20,000 inquiries by customers, each resulting in a SELECT operation on the PRODUCTS and STOCK tables. In addition, 10,000 items are sold to customers within the same time frame. The Product Sales application thus needs to update the stock status for 10,000 products per hour. Changing the stock status involves an update to the STOCK table. Once an item is created in the STOCK table, it is not deleted, so there will be no DELETEs. Finally, let’s assume that the Inventory clerks make 5,000 selects and 2,000 updates per hour and that the STOCK table is not used at all by the Human Resource application. Given these assumptions, Table 11.3 summarizes the hourly operations against the STOCK table for the three applications.

Table 11-3. Database Operations on the STOCK Table

Operation

Product Sales

Inventory

Human Resource

INSERT

None

None

None

UPDATE

10,000

2,000

None

DELETE

None

None

None

SELECT

20,000

5,000

None

The PRODUCT table is also an overlap table, and you would need to look at database operations on that table in the same manner as we just did for the STOCK table.

Configure tablespaces and deploy applications to nodes

After you’ve analyzed your database applications with respect to the tables they access, the types of operations performed by the applications on those tables, and the rate at which those operations occur, you can design tablespaces based on those access characteristics. The following sections give some general guidelines to follow for the different table types that you might encounter.

Non-overlap tables

For each application, identify tables that are not shared by any other application. These are the non-overlap tables. Put the non-overlap tables for each application in their own tablespace. The non-overlap tables of large applications may require more than one tablespace. It’s OK to use multiple tablespaces, but do not place non-overlap tables from two different applications in the same tablespace.

Warning

If you allow the non-overlap tables from different applications to share a single tablespace, they would also share the PCM locks allocated to the datafile. This situation increases the chance of false pings occurring as the result of lock contention.

In our example, the CUSTOMERS, SALES, and SALES_DETAIL tables are the non-overlap tables used by the Product Sales application and should be placed in a tablespace or tablespaces separate from all other tables. For the Inventory application, the VENDOR and RECEIPTS tables are non-overlapping and should be placed in their own separate tablespace. All of the HR tables are non-overlapping, and they should be stored separately as well.

Read-only tables

Combine all tables that have only SELECT operations on them, and place them into a separate tablespace of their own. These are your read-only tables. For example, in many applications reference tables are read-only. Also, data warehouse and data mart applications consist of mostly read-only tables. Use multiple tablespaces if necessary, but keep read-only tables separate from any others. Read-only data can be accessed by many instances in shared mode, but does not cause pinging. You can declare tablespaces containing read-only tables as read-only and allocate a single PCM lock to cover the file(s) containing the read-only tablespaces.

Concurrent insert or update tables

Concurrent INSERT and UPDATE operations from multiple instances cause contention for the segment header of the tables involved. Specify a FREELIST GROUP parameter for these tables to reduce segment header contention. In addition, preallocate extents for these tables, specifically to each instance and in the datafiles reserved for each instance. These datafiles would require separate but few PCM locks. The key factor is ensuring that the instance that initially inserts data is the same instance that also accesses the data for later DML or query operations. Chapter 9, discusses the use of FREELIST GROUP and allocation of extents to specific instances.

Read/write tables

Overlap tables that will undergo query and DML operations by many OLTP applications will cause particularly difficult contention problems. You will need to analyze each of these tables very carefully with respect to the size of the table, the type of transactions, and the transaction volume from each application. In our example, the PRODUCTS and STOCK tables are overlap tables—they are accessed by both the Product Sales and Inventory applications. Analyze these types of tables in detail, and allocate PCM locks very carefully. We recommend that you do the following:

  • For small tables, allocate a few rows per data block by assigning a high value for the PCTFREE parameter.

  • For very large tables that are accessed randomly, allocate releasable locks.

  • Consider using the data partitioning or transaction partitioning schemes discussed later in this chapter.

If the frequency of overlap operations is relatively small (up to 100 accesses per second), then pinging may occur, but it may not occur often enough to noticeably degrade performance. However, the threshold at which pinging becomes a problem is a factor of your specific OPS hardware and network characteristics.

If there is reader/writer conflict on overlap tables between OPS nodes, and you are using Oracle8i, you’ll find that the cache fusion architecture of Oracle8i reduces the performance penalty associated with this type of conflict. For example, transaction processing applications running on one node may be performing write operations on the overlap tables at the same time that reporting applications running on some other node are reading the tables. Oracle8i’s cache fusion architecture results in consistent read blocks being shipped directly from the cache of the “writer” node to the cache of the “reader” node. This transfer is done over the interconnect between the two nodes. Shipping the required blocks over the interconect is much faster than a disk-based ping operation would be. Chapter 8, discusses the benefits of cache fusion in more detail.

If many concurrent users from multiple nodes access a small OLTP application (small in this case refers to a small set of tables) and the suggestions provided in these sections are not practical, then an OPS configuration is not suitable for the application.

Tip

In an upcoming release of the Oracle database software, Oracle plans to enhance cache fusion to also handle writer/writer conflicts. Newer interconnects (such as Intel’s VI architecture) provide low latency and high bandwidth (over 1 GB). Combine these faster interconnects with the planned writer/writer implementation of cache fusion, and you’ll probably be able to implement new classes of database applications, even applications that can’t be partitioned very well, in an OPS environment while still maintaining an acceptable level of performance.

In our hypothetical example, we have two OPS nodes. The Product Sales application has more users than the Inventory and Human Resource applications combined. Therefore, we’ll assign the Product Sales application to node 1 and the Inventory and Human Resource applications to node 2. As we’ve seen during analysis, this is not a case of clean partitioning. Some overlap tables exist between the Product Sales and Inventory applications, so true pings can’t be avoided. We also will use separate tablespaces for overlap and non-overlap tables. The PRODUCTS table is one of the overlap tables and contains product codes, product descriptions, and product characteristics. This table is read only by the Product Sales application. The Inventory application, on the other hand, updates this table randomly but not very frequently. A few hashed PCM locks may be allocated to protect this tablespace because the frequency of update and hence the frequency of writer/reader conflict is less.

The STOCK table is the other overlap table. Because the stock status of various products changes as materials are received from vendors and as they are sold to customers, the STOCK table is updated frequently by both the Inventory and Product Sales applications. You should place this high-activity table in a tablespace of its own and allocate a large number of fixed hashed PCM locks to this tablespace. This will reduce the granularity of hashed PCM locks and will reduce false pings. Releasable fine-grained locks also may be used to protect this table. Releasable fine-grained locks will eliminate false pings but will have a higher overhead compared to fixed hashed locks .

Data Partitioning

With data /partitioning , also referred to as horizontal partitioning , data objects—for example, tables—are partitioned, and each OPS node accesses a set of partitions distinct from those accessed by the other nodes. In order to implement this partitioning scheme, you must do the following:

  • Partition application tables based on the value of a key column

  • Route the application to an appropriate node based on the value of the key used to partition the tables

For example, you might partition the data of a table based on a REGION column. If valid regions for our Product Sales application are East and West, then transactions from East can be routed to node 1, and transactions from West can be routed to node 2. Even though the nodes are accessing the same table, they will be accessing different partitions of that table, eliminating any contention for the same database block. You can perform data partitioning using the Oracle8 partitioning features.

Oracle8 partitioned tables

If you specify a partitioning key at the time you create a table in Oracle8, you will be able to automatically partition a table so that data in the table is stored in multiple partitions. Each partition then can be stored in its own tablespace. This feature is commonly used in data warehouse applications to manage large tables. For example, the following CREATE TABLE statement creates the SALES table with two partitions using the region_code column as the partitioning key:

CREATE TABLE sales
      (
       sale_no               NUMBER(9) NOT NULL,
       region_code           NUMBER(1) NOT NULL,
       cust_id               NUMBER(6) NOT NULL,
       sales_rep_id          NUMBER(6) NOT NULL,
       sale_date             DATE      NOT NULL,
       CONSTRAINT pk_sales   PRIMARY KEY (sale_no)
)
       PARTITION BY RANGE (region_code)
       (
           PARTITION s_east VALUES LESS THAN (2) TABLESPACE s_east,
           PARTITION s_west VALUES LESS THAN (3) TABLESPACE s_west
       );

Figure 11.4 shows the resulting partitioned SALES table with East and West partitions based on region code.

The sales table partitioned by region

Figure 11-4. The sales table partitioned by region

Data-dependent routing

Routing a transaction to an appropriate node based on the value of the data in a table requires extra application logic. Using a three-tier architecture is very helpful in implementing data-dependent routing (i.e., routing based on the value of data). In a three-tier architecture, the middle layer is responsible for routing transactions to the appropriate backend server and can be configured to route database transactions to specific nodes based on the data value of a specific column. The front-end application need not know which OPS instance is being used for any given transaction. This approach makes the design of your frontend applications independent of database location logic. You might use a product like the Tuxedo TP monitor to implement this type of data-dependent routing, as shown in Figure 11.5.

Data-dependent routing in a three-tier architecture

Figure 11-5. Data-dependent routing in a three-tier architecture

Transaction Partitioning

With transaction partitioning , individual transactions are routed to the most appropriate node based on the tables accessed by the transaction. This is different from data partitioning. Data partitioning is based on the value of a specific partition key, whereas transaction partitioning is based on the tables involved in a transaction. For example, an order entry transaction may be routed to a node that is primarily responsible for the subset of data required by order entry transactions. Stock status transactions may be routed to a different node, which is responsible for the subset of data required by those transactions. When application partitioning or data partitioning is not possible, you might choose to use transaction partitioning. Transaction partitioning is more complex. This type of partitioning, with its precise routing of transactions to appropriate nodes, is possible only in a three-tier architecture.

Transaction partitioning provides some advantages over other partitioning methods. If the data access characteristics of an application change, then individual transactions can be routed to the appropriate OPS node by changing the configuration in the middle layer. If new OPS nodes are added, then also changing the configuration in the middle layer can reroute transactions to the most appropriate node.

One way to do transaction partitioning is to route transactions to different OPS nodes during different hours of operation. For example, in a two-node OPS setup, let’s assume that transactions T1 and T2 access the common data set D1. Let’s also assume that transactions T3 and T4 access data sets D3 and D4, respectively. During the day, when the frequency of transactions T1 and T2 is high, these transactions are routed to one specific node in order to minimize contention. Transactions T3 and T4 are processed through a completely different node. At night, when the volume of T1 and T2 transactions is significantly less, and the volume of T3 and T4 transactions is quite high, T3 and T4 can be routed to different nodes. Running high-frequency transactions T3 and T4 through different nodes during the night achieves load balancing but does not cause any conflicts because these transactions access different data sets. If required, transactions T1 and T2 may be processed through different nodes at night without any problem because of the low frequency of these transactions at that time. This time-based partitioning helps to balance the overall load and also minimize concurrent access to the same data objects from different nodes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.42.243