The ActiveRecord:Relation only queries the db when its elements are accessed. So the sequence you have will not call the db at all unless you write something like u.first or tens.first.
It is a bit different in Rails console as each statement results are printed to console so it executes the query each time. You can skip the printing by appending ; 1 after each statement.
That aside, if you still want to filter the results with first query:
u = User.where(name: "bob", age: [10, 20]) # no query at this point
u.class # ActiveRecord::Relation
u.first # query to db
u.class # Array
tens = u.select{|x| x.age == 10} # no query to db