Join strategies for partitioned databases

Join strategies for a partitioned database environment can be different than strategies for a nonpartitioned database environment. Additional techniques can be applied to standard join methods to improve performance.

Table collocation should be considered for tables that are frequently joined. In a partitioned database environment, table collocation refers to a state that occurs when two tables that have the same number of compatible partitioning keys are stored in the same database partition group. When this happens, join processing can be performed at the database partition where the data is stored, and only the result set needs to be moved to the coordinator database partition.

Table queues

Descriptions of join techniques in a partitioned database environment use the following terminology:
  • Table queue (sometimes referred to as TQ) is a mechanism for transferring rows between database partitions, or between processors in a single-partition database.
  • Directed table queue (sometimes referred to as DTQ) is a table queue in which rows are hashed to one of the receiving database partitions.
  • Broadcast table queue (sometimes referred to as BTQ) is a table queue in which rows are sent to all of the receiving database partitions, but are not hashed.
A table queue is used to pass table data:
  • From one database partition to another when using interpartition parallelism
  • Within a database partition when using intrapartition parallelism
  • Within a database partition when using a single-partition database
Each table queue passes the data in a single direction. The compiler decides where table queues are required, and includes them in the plan. When the plan is executed, connections between the database partitions initiate the table queues. The table queues close as processes end.
There are several types of table queues:
  • Asynchronous table queues

    These table queues are known as asynchronous, because they read rows in advance of any fetch requests from an application. When a FETCH statement is issued, the row is retrieved from the table queue.

    Asynchronous table queues are used when you specify the FOR FETCH ONLY clause on the SELECT statement. If you are only fetching rows, the asynchronous table queue is faster.

  • Synchronous table queues

    These table queues are known as synchronous, because they read one row for each FETCH statement that is issued by an application. At each database partition, the cursor is positioned on the next row to be read from that database partition.

    Synchronous table queues are used when you do not specify the FOR FETCH ONLY clause on the SELECT statement. In a partitioned database environment, if you are updating rows, the database manager will use synchronous table queues.

  • Merging table queues

    These table queues preserve order.

  • Non-merging table queues

    These table queues, also known as regular table queues, do not preserve order.

  • Listener table queues (sometimes referred to as LTQ)

    These table queues are used with correlated subqueries. Correlation values are passed down to the subquery, and the results are passed back up to the parent query block using this type of table queue.