this post was submitted on 18 Jul 2025
134 points (97.2% liked)

Programming

21961 readers
181 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] NewNewAugustEast@lemmy.zip 40 points 2 weeks ago (8 children)

Postgres is cursed for only allowing 65535 parameters in a single query?

Someone correct me if I am wrong, but that is a fairly large number (I think Microsoft SQL is limited to 2000 or something like that) AND this seems like a terrible design pattern.

[–] msage@programming.dev 3 points 2 weeks ago (3 children)

I learned that not too long ago, too.

I mean it surprised me, but there are many ways around that. May be less efficient, but you can always use string-to-array, or json, or copy more for CTE then work with inputs as a table.

[–] ragingHungryPanda@lemmy.zip 2 points 2 weeks ago (2 children)

Create a user defined table type and use that as a parameter. I'm not sure what the postgres name of that is.

[–] msage@programming.dev 1 points 2 weeks ago (1 children)

And how do you put data into the table?

[–] ragingHungryPanda@lemmy.zip 1 points 2 weeks ago

Based on old memories since I've been working in mongo lately, after making the UDT on the db side, you make a data table that has the same name, namespace (ie dbo/public), and the same schema as the UDT (better if that could be generated) and populate it in code. Then you execute the db query with the UDT type as a parameter.

This is better for a few reasons, including not building up a string, but also having the same text means that each query didn't need to be re-parsed and can reuse execution plans. If the query text isn't an exact match, it gets that whole pipeline each time.

load more comments (4 replies)