Skip to content

TOP 0 with a constant-false HAVING clause does not eliminate aggregation #1448

Description

@chen8908917

Description

TOP 0 guarantees an empty result, and HAVING (1 = 0) independently rejects
the aggregate row. The scan and aggregation therefore cannot contribute to
the result.

Expected: the optimizer produces an empty-result plan without scanning or
aggregating rift_t.

Actual: the generated plan retains the scan and aggregate processing.

How to repeat

EXPLAIN ('SELECT TOP 0 COUNT(*) FROM rift_t');
EXPLAIN ('SELECT TOP 0 COUNT(*) FROM rift_t HAVING (1 = 0)');

Version

Virtuoso Open Source Server 07.20.3240; Virtuoso ODBC Driver 07.20.3243;
Windows x64 client; WSL2 Docker server.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions