D
D
Dmitry Larin2018-02-02 11:05:42
PHP
Dmitry Larin, 2018-02-02 11:05:42

Why use two databases PostgresSQL and MongoDB/Redis?

Please tell the person who previously worked with the LAMP stack and did not take a steam bath. Why two databases? One for big data, the other for "fast"?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maksim Fedorov, 2018-02-02
@fanrok

A relational database shows itself well for data integrity, a good and strong structure ... but there is a minus - when there are many links and tables are deep, then you have to make very large and complex queries, some can take a long time ...
Then they denormalize the data - combine several tables in one document, for example, in a document with a product, there will immediately be options with prices, and images and a category and comments, then when this document is requested by id, there is 1 request and the data is quickly returned.
For example, if there are schedules for classes that are generated by large samples, but are relevant all day, then you can cache the result for a day and return them on 1 request ...
Redis is also used to store sessions in it https://habrahabr.ru/ post/318836/

I
InoMono, 2018-02-02
@InoMono

For different purposes - their pros and cons. If MySQL is good for your workloads, then don't worry about it.
With Monga or Postgres, your site will not create itself anyway. But there is a lot of excess crap.
Situations when this extra hemorrhoid is worth it - in these two videos it is perfectly placed in its place.
https://junior.highload.ru/2016/abstracts/2075.html
https://youtu.be/SNzOZKvFZ68
If you do not have a HighLoad with database distribution on dozens or more cluster servers, RDBMS (MySQL, Postgres) is enough for you . And no consistency issues.
If you want a schemaless solution so that you don’t have to worry about migrations, then pay attention to JSONB in ​​Postgres. The author of the Highload report about this is the same O. Bartunov.
It may well be that you need a database that works with an in-memory database - Redis, Tarantool, Aerospike.
But Mongo is good for clusters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question