Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Duplicate hash codes are causing severe performance issues in Arel #205

Closed
SamSaffron opened this Issue Aug 30, 2013 · 2 comments

Comments

Projects
None yet
3 participants
fake = Arel::Nodes::SqlLiteral.new
fake << "BAR"
fake2 = Arel::Nodes::SqlLiteral.new
fake2 << "FOO"
table = Arel::Table.new("T")
table_alias = Arel::Nodes::TableAlias.new(table, "A")
table.aliases << table_alias
attrib = Arel::Attributes::Attribute.new(table_alias,"B")


p [attrib, fake].hash
p [attrib, fake2].hash

#938249829400974257
#938249829400974257

# OH NO 

In normal use in Rails there may be reference loops in Arel::Table an TableAlias, like the above.

This causes #hash in binary node to return dupe hash codes, in turn having a large number of dupe hash codes causes a seriously inefficient #uniq operation that is called in rails.

Simplest fix would be to remove .aliases from the hash to avoid these loops.

shoe commented Oct 7, 2013

Since PR #206 was merged, should this issue be closed?

Owner

rafaelfranca commented Oct 13, 2013

Right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment