diff --git a/lib/arel/algebra/attributes/attribute.rb b/lib/arel/algebra/attributes/attribute.rb
index <HASH>..<HASH> 100644
--- a/lib/arel/algebra/attributes/attribute.rb
+++ b/lib/arel/algebra/attributes/attribute.rb
@@ -29,6 +29,8 @@ module Arel
         @ancestor  == other.ancestor
     end
 
+    alias :eql? :==
+
     def named?(hypothetical_name)
       (@alias || name).to_s == hypothetical_name.to_s
     end
@@ -41,8 +43,6 @@ module Arel
       row[self]
     end
 
-    alias :eql? :==
-
     def hash
       @hash ||= name.hash + root.relation.hash
     end
diff --git a/lib/arel/algebra/relations/relation.rb b/lib/arel/algebra/relations/relation.rb
index <HASH>..<HASH> 100644
--- a/lib/arel/algebra/relations/relation.rb
+++ b/lib/arel/algebra/relations/relation.rb
@@ -187,9 +187,11 @@ module Arel
     end
 
     def position_of(attribute)
-      (@position_of ||= Hash.new do |h, attribute|
-        h[attribute] = attributes.index(self[attribute])
-      end)[attribute]
+      @position_of ||= {}
+
+      return @position_of[attribute] if @position_of.key? attribute
+
+      @position_of[attribute] = attributes.index(attributes[attribute])
     end
 
     private
no need for a lambda