in reply to Database or Storable?
If you have an index over the primary key of your table (it likely works for other columns as well) then a SELECT COUNT(*) will simply look into that index, so the DB already does the optimization you're looking for.
I'd only revert to such means if I ran into performance problems that make them absolutely necessary.
|
|---|