I’m a SWE and at my previous job it fell to me to optimize some queries that used EF Core ORM. I gave opus a local db with a small export of anonymized prod data, had it generate a billion rows with similar cardinality.
Then I told opus how to get the raw SQL and told it to write unit tests with various optimizations.
It got the query down from 5+ minutes to a few seconds. I verified the final SQL and ORM structure.
All it needed was to modify some indices and fix up the ORM to properly generate the lateral join.
However, to get the join working properly required a full restructure of the ORM query.