Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

MySQL and Postgres are awesome for a lot of what websites do. They have advantages and disadvantages. Things like sharding tend to be premature optimizations except for write-heavy sites running at high scale. I prefer a mixture of SQL and NoSQL for the projects I work on. Redis, especially, is great at things like atomic updates and counters that become cumbersome in sql. With a well architected model-layer the complexity of multiple datastores can be minimized significantly. By using the right tools for the job, we are often able to simplify even versus using one database and a hacky solution.


Isn't updating a counter in SQL just: update counters set amount = amount + 1 where id = something?


In a basic application yes this is true. But if you have a large cluster and data is spread out it becomes more difficult not to mention time consuming to run that query. With redis and other nosql solutions they are designed with this in mind so they are much faster and easier.


You didn't check for overflow.


Don't check for overflow. Simply use a data type so large that it would take centuries to overflow.

If you were doing a million increments per second it would take almost 600,000 years to overflow a 64 bit int.


Check your assumptions. The field could be updated at any time to any value by another connection.

And who's to say we started at zero.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: