Using manual logging like this turns out to be a great way to narrow down just
when and where various database operations and programming logic is occurring. As you get
more comfortable with logging as whole, you can start to add your own timers as well, so that
you will not only know when and where but also how long various sections of code take to
execute.
The final section of our log shows us the results of accessing data through our Comments
association. We bookended this information with manual comments so that we could see
what really happens when we access an association though a has_many relationship.
Once again, you see the columns queries being executed (because it??™s the first time we
accessed the comments table), and of special interest is the query that Active Record built and
executed to access our children records.
[4;36;1mSQL (0.066720) [0m [0;1mSELECT * FROM comments WHERE
(comments.account_id = 1) [0m
When performance becomes an issue within our application, we can use all of this information
to determine what SQL code could be improved, updated, or simply replaced.
Pages:
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361