You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today, queries like select count(*) from table or select count(column) from table get pushed down to docdb.
However, select count(1) from table results in a table scan and results are aggregated in postgres. We should push down this query as well.
The text was updated successfully, but these errors were encountered:
Summary:
# Problem description
While `SELECT COUNT(*)` and `SELECT COUNT(col_name)` queries were pushed down to DocDB, `SELECT COUNT(1)` was resulting in a full scan with analysis on YSQL side.
# What changed
* Allowed pusing down `Const` arguments in aggregates (in addition to `Var`s) - including `NULL` constant. This affects all aggregate functions, not just `COUNT`.
* Previously, `COUNT(*)` was sent to DocDB as `COUNT(NULL)`. Since `NULL` is no longer a placeholder value, `COUNT(*)` is transformed to `COUNT(0)` instead,
* (In the light of the change above) Changed semantics of how DocDB handles `COUNT(NULL)` - instead of counting rows it now guarantees to return 0. [To be fair, I'm not sure why original postgres code doesn't immediately evaluate this to 0]
* Slightly tweaked `TestPgPushdown` - extracted `SelectPushdownTester` as a superclass of `InClausePushdownTester`, implemented `AggregatePushdownTester` extending this superclass.
Test Plan:
ybd --java-test org.yb.pgsql.TestPgRegressTypesMisc
ybd --java-test org.yb.pgsql.TestPgPushdown
Reviewers: neha, mihnea, neil
Reviewed By: mihnea, neil
Subscribers: yql
Differential Revision: https://phabricator.dev.yugabyte.com/D8581
Today, queries like
select count(*) from table
orselect count(column) from table
get pushed down to docdb.However,
select count(1) from table
results in a table scan and results are aggregated in postgres. We should push down this query as well.The text was updated successfully, but these errors were encountered: