-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#15857] YSQL: support IndexScan aggregate pushdown
Summary: Before this change, aggregate pushdown is supported by ForeignScan, IndexOnlyScan, and YbSeqScan. Support it for IndexScan. See D26556 for a similar change with more detailed summary. Unlike previous cases, index scan aggregate pushdown involves - Binds to the index: nothing special for aggregate pushdown. - Targets to the table, bound on ybctids received from the index: this exercises a different codepath on DocDB side, so modification is needed there. And because server-side needs modification, rolling upgrade-support is added using auto pg flag on a new GUC yb_enable_index_aggregate_pushdown. Jira: DB-5261 Test Plan: ./yb_build.sh fastdebug --gcc11 --java-test TestPgRegressAggregates ./yb_build.sh fastdebug --gcc11 \ --java-test TestPgRegressFeaturePartition ./yb_build.sh fastdebug --gcc11 \ --java-test 'TestPgPushdown#aggregatesVar' Upgrade test: #!/usr/bin/env bash set -euxo pipefail # Create old release cluster. PREFIX=${1:-/tmp} if [ ! -d "$PREFIX"/yugabyte-2.18.1.0 ]; then curl "https://downloads.yugabyte.com/releases/2.18.1.0/yugabyte-2.18.1.0-b84-linux-x86_64.tar.gz" \ | tar xzv -C "$PREFIX" fi "$PREFIX"/yugabyte-2.18.1.0/bin/post_install.sh "$PREFIX"/yugabyte-2.18.1.0/bin/yb-ctl destroy "$PREFIX"/yugabyte-2.18.1.0/bin/yb-ctl create --rf 3 # Need to use release build to be compatible with release archives. ./yb_build.sh release --sj # Rolling upgrade: upgrade masters first. for idx in {1..3}; do "$PREFIX"/yugabyte-2.18.1.0/bin/yb-ctl stop_node --master "$idx" bin/yb-ctl start_node --master "$idx" done # Rolling upgrade: upgrade one tserver. "$PREFIX"/yugabyte-2.18.1.0/bin/yb-ctl stop_node 1 bin/yb-ctl start_node 1 # Wait for ysqlsh to be ready (yb-ctl seems to not properly take care of this) while ! bin/ysqlsh -c ''; do sleep 1; done # Query should succeed without pushdown. output=$(bin/ysqlsh -X -v "ON_ERROR_STOP=1" <<EOT SHOW yb_enable_index_aggregate_pushdown; CREATE TABLE t (i int, j int); CREATE INDEX NONCONCURRENTLY ON t (i ASC); INSERT INTO t SELECT g, -g FROM generate_series(1, 100) g; \set query 'SELECT SUM(j) FROM t WHERE i > 4' EXPLAIN :query; :query; EOT ) grep "^ off$" <<<"$output" grep "Partial Aggregate: true" <<<"$output" && exit 1 grep "^ -5040$" <<<"$output" # Rolling upgrade: upgrade remaining tservers. for idx in {2..3}; do "$PREFIX"/yugabyte-2.18.1.0/bin/yb-ctl stop_node "$idx" bin/yb-ctl start_node "$idx" done # Rolling upgrade: run ysql upgrade. build/latest/bin/yb-admin \ -master_addresses=127.0.0.1,127.0.0.2,127.0.0.3 \ upgrade_ysql # Rolling upgrade: promote auto-flags. build/latest/bin/yb-admin \ -master_addresses=127.0.0.1,127.0.0.2,127.0.0.3 \ promote_auto_flags for idx in {1..3}; do while ! curl "127.0.0.$idx:9000/api/v1/varz" \ | grep -q 'ysql_yb_enable_index_aggregate_pushdown","value":"true'; do sleep 1 done done # Query should succeed with pushdown. output=$(bin/ysqlsh -X -v "ON_ERROR_STOP=1" <<EOT SHOW yb_enable_index_aggregate_pushdown; \set query 'SELECT SUM(j) FROM t WHERE i > 4' EXPLAIN :query; :query; EOT ) grep "^ on$" <<<"$output" grep "Partial Aggregate: true" <<<"$output" grep "^ -5040$" <<<"$output" Close: #15857 Reviewers: amartsinchyk Reviewed By: amartsinchyk Subscribers: ybase, yql Differential Revision: https://phorge.dev.yugabyte.com/D27427
- Loading branch information
Showing
20 changed files
with
842 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.