Skip to content

NextUniqueInt in Preload does not play nice with pgx's statement caching #741

Description

@jalaziz

By default, pgx automatically caches queries as prepared statements. While there are some limitations, it generally helps with performance and makes prepared statements an after thought.

Unfortunately, we ran into a footgun with Preload's use of NextUniqueInt. Since NextUniqueInt runs a global counter and increments on every build / exec of the query, it effectively negates any of the prepared statement caching that pgx does and appears to cause an increase in memory usage.

Combined with bob not supporting explicit prepared statements when using the pgx driver (it doesn't implement Preparer), the average user is left with suboptimal performance out of the box.

The relatively simple workaround is to provide static PreloadAs aliases when joining via Preload.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions