**user.rb**

```
has_many :programs, dependent: :destroy
def active_program
    programs.where(active: true).limit(1).first
end

```

**schema.rb**

```
add_index "programs", ["active"], :name => "index_programs_on_active"
add_index "programs", ["user_id"], :name => "index_programs_on_user_id"

```

There are only 105 rows in the programs table.

Here is part of a New Relic trace breakdown for a single request, edited to focus on the relevant components.

![enter image description here](https://i.stack.imgur.com/wSxYT.png)

I don't understand why these two components are taking so long.

I'm assuming `Program#find_by_sql` is using the default query tracing, and therefore is not executing an actual query 57 times, but why then is it taking 1350ms to do a simply query on a small table?

Also, why would `user.active_program` be taking 1070ms, when all it does it call the query?

I'm using Rails 3.2.13 and Ruby 1.9.3p429.