View Single Post
Old 04-03-2009, 03:28 PM   #18 (permalink)
allworknoplay
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by WebSavvy View Post

@allworknoplay -- that's a good field to use to get a correct count if it's for a users db like you mention. It all depends on what the ID is for.

Example: I have a categories table with over 200,000 categories in it. Each one has a category #ID which is the primary field.

Then, there is another table which lists records indexed in each category and it too has an ID field.

In the categories table using count(ID) would tell me how many categories I have as there wouldn't be any null fields for this.

In the listing table, I don't use the count(ID) because some records that are inserted are ones that haven't been reviewed by an editor. I end up using two fields to get the active count for a category:

`url` and `queue`

If there are X-amount of `urls` in live `queue`, then I know how many records are active.

So, that said, it really depends on the data set you're trying to define.

Thanks Websavvy, that makes perfect sense to me. I too use myisam as my DB engine. I guess I probably should have mentioned that since a different engine could possibly behave differently...

I don't really know all that much about innodb anyways...
allworknoplay is offline  
Reply With Quote