question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Queries with more than 32k parameters are allowed

See original GitHub issue

version: 8.0.3

As far as I understand, a query can have up to max int16 parameters (from https://www.postgresql.org/docs/devel/protocol-message-formats.html). I found out in my logs error messages like the following.

ERROR:  bind message has 52708 parameter formats but 0 parameters

The means that the prepare message was fine expecting 52708 parameters? and if that’s the case how would that be handled? that takes me the “0 parameters”. I am plainly executing a query, how is it that 0 parameters showed up?

Thank you.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
AlexGalayscommented, Oct 7, 2021

That error message means you’ve got 52708 placeholders, but no values passed in.

The maximum is 65535, which the only way you can hit if you are using it the wrong way. You should be splitting those across queries or hold inside an array, not bundle all into one query. See also here.

That’s not correct.

Currently, there’s an issue where you will see this weird error message even if you pass values and the length of values is exactly the same as the parameter formats. It just throws this error when you’re over 64K parameters.

Tested just now:

There’s always 4 columns worth of parameters per row (So ($1, $2, $3, $4) is the first row). Turns out the number in the error message is by how much you exceed the 64K limit; it seems the rest gets dropped but it results in a hard to understand error message.

112720 parameters/values;  bind message has 47184 parameter formats but 0 parameters

94896 parameters/values;  bind message has 29360 parameter formats but 0 parameters

91488 parameters/values;  bind message has 25952 parameter formats but 0 parameters

77616 parameters/values;  bind message has 12080 parameter formats but 0 parameters

66936 parameters/values;  bind message has 1400 parameter formats but 0 parameters

43824 parameters/values => works fine.

Surely the error message could be more helpful in tracing back to the actual problem?

2reactions
vitaly-tcommented, Jul 26, 2021

That error message means you’ve got 52708 placeholders, but no values passed in.

The maximum is 65535, which the only way you can hit if you are using it the wrong way. You should be splitting those across queries or hold inside an array, not bundle all into one query. See also here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there any possibility for a workaround to PostgreSQL 32760 ...
There is a hard limit of bound parameters in a SQL statement. You just discovered it, 32760. For those types of queries it's...
Read more >
Procedure accepting more than 32K text as a parameter and in...
This procedure should accept text more than 32K. Now I know that there is limit for PLSQL variable i.e 32K.
Read more >
Configuration Parameters | Tanzu Greenplum Docs
The Postgres Planner will merge sub-queries into upper queries if the resulting FROM list would have no more than this many items. Smaller...
Read more >
What Is The Maximum Length Of A Text Value In Power BI?
It turns out that this is a more complex question than you might think! The maximum length of a text value that the...
Read more >
Use parameters to ask for input when running a query
To make a query in Access desktop databases ask for criteria when you run it, create a parameter query. This allows you to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found