Q023hint

Count wraps the query

The generated count query wraps the SELECT because it has GROUP BY, DISTINCT or a window function.

db/queries/example.sql:1:1: hint[Q023]: a dynamic: runtime query returns rows other than those it reads, through GROUP BY, HAVING, DISTINCT, an aggregate or window function, or a compound; .Count(ctx) wraps the original in a subquery so the count reflects outer-result rows rather than the underlying table
Printed by sgl from a small PostgreSQL reproduction project.

When it is reported

The count becomes SELECT COUNT(*) FROM (query) sub, so Count(ctx) returns the number of result rows rather than the number of table rows.

How to fix it

Nothing to fix.

See it in an example

In your terminal

$ sgl explain Q023

Look for CountSemanticsWrapped in Seagull's source to see where it is reported.