Skip to content

HEAD request unnecessarily sends query data back to PostgREST #2849

Closed
@bnjmnt4n

Description

@bnjmnt4n

Environment

  • PostgreSQL version: 15.2
  • PostgREST version: 10.2
  • Operating system: Ubuntu 20.04, WSL

Description of issue

Sending a HEAD request actually executes the query and sends the aggregated JSON query results back to PostgREST, even though the response will just be discarded. I think PostgREST should just compute the count and send that back alone, to avoid unnecessary CPU and I/O operations for something which is just discarded.

I ran into this whilst using a HEAD request with Prefer: count=exact. Adding an explicit limit=0 to avoid actually sending any data decreased the response timing by nearly half.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions