Skip to main content

Sort pushdown

KlustronDBLess than 1 minute

Sort pushdown

Preface

In the previous two articles, we introduced the query optimization process of KlustronDB and Project and Filter pushdown. This section explains sort query optimization through sort pushdown.

1. Push down order by

The execution plan of an SQL containing order is generated in the following process, where Sort is pushed down into the RemoteScan operator.

The push operation of Sort is asynchronous. Instructions are executed in parallel on each data node, and after filtering the data, the sorted results are sent back to the computing nodes, reducing the load on the computing nodes.

Next, let's test and check the execution plan for query pushdown

To support pushdown of sorting, the following parameters need to be set to true in KunlunDB:

set enable_remote_orderby_pushdown=true;

Test sentence:

select c_zip from customer1 order byc_zip;

View execution plan:

explain select c_zip fromcustomer1 order by c_zip;

According to the above execution plan, RemoteScan conveys the remote sorting operation to each relevant storage node, and the storage nodes return the results to the computing node for Merge Append.

If the sort pushdown feature is disabled, the execution plan will change, and the sort operation will be performed on the compute node.

The demonstration is as follows:

set enable_remote_orderby_pushdown=false;

The sorting operation will be performed on the compute node:

Execution process of the statement: After the statement is rewritten on the compute node, it is sent to 2 data nodes for execution. The values that meet the conditions are pulled from the compute node to the compute node for sorting, and after sorting, it is fed back to the client.

END