开发者

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

开发者 https://www.devze.com 2023-02-15 05:01 出处:网络
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:

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

精彩评论

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