Describe the feature

Add support for using JOIN instead of the IN clause when using Preload in GORM. Currently, Preload internally constructs queries using IN (?), which causes issues when preloading large datasets due to PostgreSQL's 65,535 parameter limit. A configurable option to switch Preload strategy to JOIN would allow for more scalable data fetching in high-volume applications.

Motivation

When working with a large number of parent records and preloading their associations, GORM’s use of the IN clause quickly hits PostgreSQL’s limit on bind parameters. This results in failed queries and limits GORM's usability in large-scale applications. Allowing a JOIN-based preloading strategy would prevent hitting this limit and improve performance and reliability in many real-world scenarios.

Related Issues

Possibly related to internal performance limitations or past discussions on scalable preloading, though I couldn’t find a specific open issue addressing the JOIN alternative to IN in Preload.