EXCHANGE operator

The EXCHANGE operator marks the boundary between a producer and a consumer operator (the operators below the EXCHANGE operator produce data and those above it consume data). Example A, which showed parallel scan of the titles table (select * from titles), the EXCHANGE: EMIT and the SCAN operator produce data. This is shown briefly.

select * from titles

The type of query is SELECT.

ROOT:EMIT Operator

    |EXCHANGE Operator (Merged)
    |Executed in parallel by 3 Producer and 1 Consumer
           processes.
    |
    |    |EXCHANGE:EMIT Operator
    |    |
    |    |    |RESTRICT Operator
    |    |    |
    |    |    |    |SCAN Operator
    |    |    |    |  FROM TABLE
    |    |    |    |  titles
    |    |    |    |  Table Scan.

In this example, one consumer process reads data from a pipe (which is used as a medium to transfer data across process boundaries) and passes the data to the emit operator, which in turn routes the result to the client. The exchange operator also spawns worker processes, which are called producer threads. The exchange:emit operator writes the data into a pipe managed by the exchange operator.

Figure 5-1: Binding of thread to plan fragments in query plan

Graphic showing process bundaries sectioned as one consumer process resulting in a process boundary and three producer processes.

Figure 5-1 shows the process boundary between a producer and a consumer process. There are two plan fragments in this query plan. The plan fragment with the scan and the exchange:emit operators are cloned three ways and then a three-to-one exchange operator writes it into a pipe. The emit operator and the exchange operator are run by a single process, which means there is a single clone of that plan fragment.