counter vs. select count

  • for a system where items can be added, used for a while and then be made available again i would like to display the number of items that are available when the user lists the items...is it better to query a column with a counter which will be decremented each time an item is used or to do a select count to determine how many items are available based on the value in an availablity column? i think the counter column would be produce quicker results than the select statement, especially for longer lists...but what if two people click to use an item simultaneously...this could an incorrect result to be entered in the counter field...

  • Have to test on your system and see. How many items? If it's not a large enough table, it will be scanned anyway.

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

    http://www.dkranch.net

  • i think i'll use transactions to ensure locking of rows being modified until the whole process is complete.

    Edited by - pliant on 05/20/2003 10:43:34 AM

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply