N
N
Nikolai Kokoulin2017-10-02 21:22:26
PostgreSQL
Nikolai Kokoulin, 2017-10-02 21:22:26

DB structure for storing comments?

Given:
650 million comments (one table)
Id, text, time, rating, related_img, related_link user (20 million records), article (140 thousand records), category (50 records), parent comment (650 million)
Peak load:
Reading 50 rps
Write 7rps
Opportunity to leave a comment on the news disappears after 1 month
Task: make a normal database structure to store this
Stack:
pgsql
Symfony 3.2
Doctrine
Redis

Answer the question

In order to leave comments, you need to log in

4 answer(s)
N
Nikolai Kokoulin, 2017-10-03
@Kokoulin

Thank you all for the answers, it was decided to store the comments in the radish link entirely, the old ones only an indication of the storage location

V
Vyacheslav Uspensky, 2017-10-03
@Kwisatz

Looks like a work order
. What exactly is the question?
- In a parent/child relationship? parent_id
- In tree selection? with recursive
- Want to separate records by time? sharding with UPD condition
:
one
two
three

A
AlikDex, 2017-10-03
@AlikDex

split into 2 tables? 1 with the news of a month ago, the rest in the archive.

X
xmoonlight, 2017-10-03
@xmoonlight

The selection should be in 2 stages (given that all indexes in the database are correct!).
1. Select all comments for the current post using only one Id column.
2. Then - we work only with these comments from the intermediate selection (when receiving data for display on the page, etc.).
3. You can add cross-links if the selection of comments should be not only from the side of the post, but also from the side of a specific user, category, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question