Running a query that gets distributed

DQP introduces leader and worker nodes. A leader node is where a query originates. A worker node can be any node in the multiplex that is capable of accepting distributed query processing work.

Any multiplex node type (reader, writer, or coordinator) can be a leader or a worker node. When a client submits a query to the server, the query optimizer uses a cost analysis to determine whether to execute a parallel or distributed query. A parallel query is broken into query fragments of predicates and data flow subtrees. A query fragment can be distributed only if the Sybase IQ engine supports parallel and distributed execution of the query operators contained in the fragment.

When a query is distributed, the leader node assigns query fragments to worker nodes. Worker nodes do not make decisions about query distribution. They simply execute the work assigned to them and return intermediate results from the worker servers. A query is likely to get distributed when it uses a large number of rows. For example, queries on star schemas may benefit greatly from distributed query processing.

If the query optimizer determines that a distributed query is unlikely to scale appropriately, or might even degrade performance, the query is not distributed and is executed on a single node in the multiplex.

StepsRunning a distributed query

Before running distributed queries, increase the file size in user dbspace iq_main.

  1. In Interactive SQL, open and execute:

    On UNIX$SYBASE/IQ-15_3/demo/dqpdata.sql.

    On Windows%ALLUSERSPROFILE%\SybaseIQ\demo\dqpdata.sql.

    This creates the Dimension table and the Fact table (10 million rows).

  2. In Interactive SQL, open and execute:

    On UNIX$SYBASE/IQ-15_3/demo/dqpquery.sql.

    On Windows%ALLUSERSPROFILE%\SybaseIQ\demo\dqpquery.sql.

    This query fetches three rows and generates query plans as HTML files in your demo directory and in the write server's directory. The query also writes the paths into the .iqmsg file.

    NoteIssue a ROLLBACK command from Interactive SQL after the three rows return to force Sybase IQ to flush the query plans.

  3. Check the multiplex node directories for query plan HTML files. The leader node’s directory has the comprehensive query plan, and each work unit distributed has an HTML file generated by the node that received it. Double-click the leader node’s query plan to open it in a Web browser.

    Figure 24: Query tree for distributed query

    Graphical query tree is a series of stacked boxes joined by vertical bars. Three vertical bars join the Group By Hash and Join Hash boxes and the Parallel Combiner and Group By Hash boxes. Three vertical bars also join the Join Hash and 01 Leaf boxes.

    The three vertical bars that connect the query operators in the graphic indicate distribution. For example, between the group by node and the join, the three bars indicate that this operation occurs over parallel threads and is distributed over multiple servers. The operation between the join and leaf #01 is also distributed.