Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple count=estimated and db-max-rows #3651

Open
wolfgangwalther opened this issue Jul 10, 2024 · 4 comments
Open

Decouple count=estimated and db-max-rows #3651

wolfgangwalther opened this issue Jul 10, 2024 · 4 comments
Labels
enhancement a feature, ready for implementation

Comments

@wolfgangwalther
Copy link
Member

Currently to use count=estimated we'll need to use db-max-rows. But db-max-rows applies to all requests, which is pointless.

I want to be able to:

  • Download the full result set without any limit applied (up to 300k rows in my case)
  • Have the ability to use count=estimated for a much lower limit, when I paginate through the resultset.

Maybe we can introduce an option to pass the "estimation limit" to the prefer header directly?

Something like Prefer: count=estimated(1000), which would apply the LIMIT 1000 only inside the pgrst_source_count CTE:

pgrst_source_count AS (
  SELECT 1
  FROM "pgrst_source" AS "training_report"
  LIMIT 1000
)
@wolfgangwalther wolfgangwalther added the idea Needs of discussion to become an enhancement, not ready for implementation label Jul 10, 2024
@wolfgangwalther
Copy link
Member Author

It seems like the LIMIT is already applied inside pgrst_source_count for regular requests. In my case I am requesting from an RPC, and it seems db-max-rows is not applied at all.

@wolfgangwalther
Copy link
Member Author

It seems like the LIMIT is already applied inside pgrst_source_count for regular requests.

Thus, it would then be more like "apply a LEAST(1000, db-max-rows)" limit inside the count CTE.

@wolfgangwalther
Copy link
Member Author

Something like Prefer: count=estimated(1000),

Alternatively, just a new config option db-max-count, which defaults to db-max-rows, but allows us to set the max count limit without enforcing a max-rows limit in general.

@steve-chavez steve-chavez added enhancement a feature, ready for implementation and removed idea Needs of discussion to become an enhancement, not ready for implementation labels Jul 15, 2024
@steve-chavez
Copy link
Member

Perhaps db-max-count could solve #3576 too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement a feature, ready for implementation
Development

No branches or pull requests

2 participants