Describe the feature

Use pq.Array({ids}) as parameter and = ANY(?) SQL syntax instead of IN (?) when preloading objects in Postgres.

Motivation

If one has to preload too many elements, Postgres fails with the following for instance: pq: got 82000 parameters but PostgreSQL only supports 65535 parameters

Additionally, parsing a lot of strings in IN (...) is very slow in Postgres, the = ANY(...) syntax is much faster, since IN can contain a SELECT-statement at any point, whereas = ANY() cannot.

It would be a specific enhancement for the Preloader when using Postgres. I would gladly write the changes myself, if anyone can point me in the right direction.

Related Issues

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 2 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: lifegit

excuse me, have you solved it?

Comment From: svip

I ended up writing a preloader that ignores GORM's Preload() entirely. But it's kind of hooked up to our own types rather than being a generic drop-in replacement for others. So for my own purposes, I solved the issue, but for a GORM issue, I did not solve it.

Comment From: lifegit

I ended up writing a preloader that ignores GORM's Preload() entirely. But it's kind of hooked up to our own types rather than being a generic drop-in replacement for others. So for my own purposes, I solved the issue, but for a GORM issue, I did not solve it.

excuse me,Is it convenient for you to give an example?