Andreas Lyngstad
Andreas Lyngstad

Reputation: 4927

Rails logs. what does this mean

I get This on my development log. What does the mCACHE lines mean? Are they SQL queries?

 ←[1m←[36mTodo Load (1.0ms)←[0m  ←[1mSELECT "todos".* FROM "todos" WHERE ("todos".project_id IN (4,5,6,7,8,9,10,11,12,13))←[0m
 ←[1m←[35mLog Load (1.0ms)←[0m  SELECT "logs".* FROM "logs" WHERE ("logs".todo_id IN (134,135,136))
 ←[1m←[36mCACHE (0.0ms)←[0m  ←[1mSELECT "firms".* FROM "firms" WHERE ("firms"."id" = 2) LIMIT 1←[0m
 ←[1m←[35mCACHE (0.0ms)←[0m  SELECT "users".* FROM "users" WHERE ("users"."id" = 3) LIMIT 1
 ←[1m←[36mCACHE (0.0ms)←[0m  ←[1mSELECT "users".* FROM "users" WHERE ("users"."id" = 3) LIMIT 1←[0m
 ←[1m←[35mCACHE (0.0ms)←[0m  SELECT "users".* FROM "users" WHERE ("users"."id" = 3) LIMIT 1
 ←[1m←[36mCACHE (0.0ms)←[0m  ←[1mSELECT "firms".* FROM "firms" WHERE ("firms"."id" = 2) LIMIT 1←[0m
 ←[1m←[35mCACHE (0.0ms)←[0m  SELECT "firms".* FROM "firms" WHERE ("firms"."id" = 2) LIMIT 1
 ←[1m←[36mCACHE (0.0ms)←[0m  ←[1mSELECT "firms".* FROM "firms" WHERE ("firms"."id" = 2) LIMIT 1←[0m
 ←[1m←[35mCACHE (0.0ms)←[0m  SELECT "firms".* FROM "firms" WHERE ("firms"."id" = 2) LIMIT 1
 ←[1m←[36mCACHE (0.0ms)←[0m  ←[1mSELECT "firms".* FROM "firms" WHERE ("firms"."id" = 2) LIMIT 1←[0m
 ←[1m←[35mCACHE (0.0ms)←[0m  SELECT "firms".* FROM "firms" WHERE ("firms"."id" = 2) LIMIT 1
 ←[1m←[36mCACHE (0.0ms)←[0m  ←[1mSELECT "firms".* FROM "firms" WHERE ("firms"."id" = 2) LIMIT 1←[0m
 ←[1m←[35mCACHE (0.0ms)←[0m  SELECT "firms".* FROM "firms" WHERE ("firms"."id" = 2) LIMIT 1
 ←[1m←[36mCACHE (0.0ms)←[0m  ←[1mSELECT "firms".* FROM "firms" WHERE ("firms"."id" = 2) LIMIT 1←[0m

Upvotes: 2

Views: 1824

Answers (3)

rwilliams
rwilliams

Reputation: 21497

Cache means that you've already run the same query and it's result is stored in memory, so the query isn't actually run against the database. They are all queries, it's what Active Record actually does when it talks to the database.

Upvotes: 2

gdelfino
gdelfino

Reputation: 11181

That is the evidence that Rails SQL Caching is working:

http://guides.rubyonrails.org/caching_with_rails.html#sql-caching

Upvotes: 3

Piskvor left the building
Piskvor left the building

Reputation: 92772

The [numberm are just ANSI color codes - it's supposed to show pretty colors in a smart terminal, looks bad otherwise.

The CACHE is "an sql query, cached (executed previously, now loaded from cache)" - see e.g. this

Upvotes: 4

Related Questions