实现“未读评论”的有效系统计数器 [英] Implementing an efficient system of "unread comments" counters

查看:127
本文介绍了实现“未读评论”的有效系统计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为以下问题找到一个最佳解决方案:需要设计一个数据库(基于postgres),触发器和计数器的系统,它将形成一个系统有效地查询,更新和存储关于每篇文章(或博客条目,或类似的)中存在多少未读评论的信息。



每个解决方案到头部,在查询或存储或更新部分中具有一些严重的缺点。也就是说它需要太多的存储空间,或太多的更新或太昂贵的查询。



您的到期时间怎么样?

解决方案

我会保持架构尽可能简单,所以,查询将尽可能简单。这通常也具有最低的存储要求。当然,设置索引以支持这个查询。



下一步:测量性能! 测量就是知道。什么是响应时间?服务器上的负载是多少?只要性能是可以接受的,保持模式和查询简单。



如果性能确实是一个问题,请查看框架的缓存功能您正在为您的应用程序使用。不执行查询总是比执行优化的更快。


I am trying to find an optimal solution for the following problem: there is a need to design a database (postgres-based), the system of triggers and counters in it, which will form a system of efficiently querying, updating and storing information on 'how much unread comments exist in each article (or blog entry, or smth. similar), that is displayed on the page'.

Every solution that comes to the head, has some serious disadvantages, either in querying, or the storing, or the updating part. I.e. it needs too much storage, or too much updates, or too costy queries.

What about your expirience? Maybe there is an already formed nice solution for this kind of problems?

解决方案

I would keep the schema as simple as possible, so querying will be as simple as possible. This usually also has the lowest storage requirements. Of course, set indices to support this query.

Next step: measure the performance! "To measure is to know." What is the response time? What is the load on the server? As long as the performance is acceptable, keep the schema and query simple. Do not sacrifice maintainability if it is not absolutely necessary: your successors will thank you for it later.

If performance really is a problem, look at the caching functionality of the framework you are using for your application. NOT performing a query is always faster than performing an optimized one.

这篇关于实现“未读评论”的有效系统计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆