开发者

Rails: How to find out how many items stored in database?

To find out how many jobs are stored in database I do:

Job.all.size

Is this th开发者_如何学Ce best way to do this ?


You can do:

Job.count

This will do a

SELECT COUNT(*) FROM "jobs" 

in the database...


The size will use the counter cache field if available.

The count always perform the database query.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜