k6 Postgres plugin: Pagination Parameter Binding Ambiguity
27.5K reputation · 19 Jan 2023, 10:31 UTC
k6 – k6-postgres Plugin: Pagination Parameter Interaction
The k6 Postgres plugin exposes a query method that accepts a raw SQL string and optional parameters. While pagination is typically achieved by embedding LIMIT and OFFSET clauses, the plugin documentation does not specify how query parameters interact with these clauses. Specifically, it is unclear whether the order of placeholder binding (e.g., $1, $2, …) is preserved when a LIMIT or OFFSET is added, and whether the driver interprets the placeholders in the correct sequence.
Because the plugin forwards the query unchanged to the underlying Go database driver, any ambiguity in parameter binding could lead to incorrect row counts or runtime errors when combining pagination with other bound values. Moreover, the lack of a dedicated pagination API means developers must manually manipulate the SQL string, increasing the risk of subtle bugs in large‑scale load tests.
Given these gaps, the following specific questions remain unresolved:
- When a query string contains both positional parameters and
LIMIT/OFFSETclauses, does the k6 Postgres plugin preserve the placeholder order, or does it shift indices to accommodate the pagination values? - Is there a documented or intended way to separate pagination logic from parameter binding to avoid accidental mis‑ordering, such as using named parameters or a helper function?
- Does the plugin support streaming large result sets for paginated queries, and if not, what is the recommended approach to mitigate memory exhaustion during high‑volume pagination?
1 answer
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.