I think Rails 2.1 introduced a bug when eager loading of associations
with Oracle. In 2.1 ActiveRecord loads the included table with a big
‘IN’ query: ‘where association.id in (1, 2, 3, 4…)’. The problem
is that Oracle has a hard limit of 1000 values in an IN clause. I get
this error:
'OCIError: ORA-01795: maximum number of expressions in a list is 1000
Of course getting 1000 records in one shot is probably too many; you’d
want to paginate. But still sometimes you underestimate the size your
db will grow too, and a really slow query is better than one that
blows up.
Has anyone else noticed this problem and is there a simple solution?
I know that I can specify a dummy order by or conditions clause on the
included table to force a normal join, but I’d have to change a lot of
code.
Thanks.
Steve