I am working on a C++ app and making inserts into a local postgres database using the libpq library. I am running into an issue where if I attempt to query the database with a prepared statement, the query appears to hang if the parameters are too long (specifically this starts to happen at exactly 393167 characters [combined character count of paremeters]). I am new to psql so I will try to be as specific as I can. Let me know if more information is needed.
Here are some notes / steps I took so far:
- I changed the log_statments to 'all' in postgresql.conf. It appears that the query is reaching the database because it's logging the query.
- If the the lengths of the paramters is even one less (393166) it will run with no issue.
- If I run a similar INSERT query through libpq without parameters/prepared statement and just execute directly, it runs fine for much larger queries (millions of characters). EX:
insert into...values('test12', 'aaa....');
- It doesn't seem to matter what the characters are.
- Query performance doesn't slow down as it approaches this limit. It's very fast but appears to hit a wall when it reaches this character limit.
- I've increased work_mem to the maximum allowable "2097151kB", but that hasn't helped. I am guessing that there is some issue with my postgres setup but I'm having a lot trouble figuring out what it could or where to look.
Here is an example query: (As it appears in the logs)
2023-05-04 16:25:04.657 CDT [36340] LOG: execute 2: INSERT INTO public.knowledge
(userid, knowledge) VALUES ($1, $2)
2023-05-04 16:25:04.657 CDT [36340] DETAIL: parameters: $1 = 'test12', $2 =
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.....'