4 ms·
Great solution, thanks for sharing. At this point, I wonder: with a huge dataset, wouldn't you have better time leaving the count field out of postgres altoget
by oelmekki 10y ago
Great solution, thanks for sharing.
At this point, I wonder: with a huge dataset, wouldn't you have better time leaving the count field out of postgres altogether and use something like redis with its INCR/DECR instructions instead? This would prevent having deadlocks as well.
EDIT: that is, if you don't need to use the count field in other queries.
- rowanseymour 10y agoWe've found that Redis works great for counting some things, but when you need a count which is guaranteed to match what is in a db table, it's preferable to manage counts at a db level. Often we're making counts based on the state of a record, and it's easy for the application level view of things to end up stale.