Pritesh Jain
Pritesh Jain

Reputation: 9146

how to check of query from database retrieved or cache

I have following queries from rails logs

  1. Called to database

     Userdetail Load (0.1ms)  SELECT `userdetails`.* FROM `userdetails` WHERE `userdetails`.`user_id` IN (3, 4)
    
  2. Called to Cache

    CACHE (0.0ms)  SELECT `userdetails`.* FROM `userdetails` WHERE `userdetails`.`user_id` = 3 LIMIT 1
    
  3. Unknown

    (0.1ms)  SELECT COUNT(*) FROM `votes` WHERE `votes`.`voter_id` = 3 AND `votes`.`voter_type` = 'User' AND `votes`.`votable_id` = 5690 AND `votes`.`votable_type` = 'Post'
    

There is no LOAD or CACHE word indicating the store in type 3

How do I know where this query was performed?

Upvotes: 1

Views: 68

Answers (1)

Anthony Alberto
Anthony Alberto

Reputation: 10405

I think it's because you're doing a count. CACHE would have been written anyway if it was sent to the cache, my guess is that it was performed on the DB.

To verify this, you could try to execute the query several times in a row, the subsequent calls should be marked as CACHE

Upvotes: 1

Related Questions