Hello and thank you for reading my question!
Currently, we use PostgreSQL v.10 on 3 nodes through stolon (https://github.com/sorintlab/stolon) We have 3 tables (I want to make my question simple):
- Invoice (150 000 000 records)
- User (35 000 000 records)
- User_Address (20 000 000 records)
The main query looks like this (The original query is a large, using a temporary table and have a lot of where conditions, but the sample shows my problem.)
select
i.*
from invoice as i
inner join get_similar_name('Jon') as s on i.name ilike s.name
left join user_address as a on i.user_id = a.user_id
where
a.state = 'OH'
and
i.last_name = 'Smith'
and
i.date between '2016-01-01'::date and '2018-12-31'::date;
The function get_similar_name
returns similar names (example: get_similar_name('Jon') will return John, Jonny, Jonathan ...
etc) average 200 - 1000 names. I must use the function :\
The query was executed a long time, around 30 - 120 seconds,
but if I exclude the function get_similar_name
from the query, then execution time will be not more then 1 second.
I already configured PostgreSQL and the server working pretty good. I also created indexes and my query don't use seq scan and etc.
We don't have the possibility to make partitioned tables because we have a lot of columns for this. We can't divide a table only by one row.
I think about migrating my warehouse to MongoDB
My questions are:
- Am I right about moving to MongoDB?
- Increase performance if I move warehouse from PostgreSQL to 20-40 nodes under MongoDB control?
- Is it possible to have the function
get_similar_name
on MongoDB or similar solution? If yes, how? - Do you have good experience to use fulltext search in MongoDB?
- Is it right way to use MongoDB on production?
- Can you please advise a "google-vector" to right solution on your opinion?