In one project I save statuses of processing in MySQL table:
`id` `name` `email` `has_apples` `has_bananas`
1 Bob a@b.c 1 0
2 Mike c@d.e 0 1
3 John 1 1
name
+email
pair should be unique.
For now everything works fine. But the table grows rapidly, and currently it contains about 100m rows.
According to the development needs I have to add, lets say, has_oranges
column.
Altering such a big table is painful, requires downtime and it doesn't look like that the MySQL is a right tool for this problem.
Even more, the number of such type of data will grow in the future.
I'm looking for a long-term scalable solution, which will allow:
- fast search by id
- fast search by name
- unique control of the
name
+email
pair - column scalable
- storage scalable
I'm not familiar with NoSQL solutions, but it seems that maybe that's the way to go.
Best Answer
I think you're way off in what requires NoSQL and big data. By at least a few orders of magnitude:
Using PostgreSQL
Following my own advice and creating an email type here is an example,
Keep in mind, some of that time is spent validating the email addresses against the HTML5 spec. Anyway, that all finishes in
720882.332 ms
or 12 minutes on my rusty laptop. Keep in mind, that's without the indexes. Now we add the indexes.Tada, test data done.
Adding columns like that is probably not a good idea, why not use the
jsonb
typeEtc., Not sure what you mean by "scalable storage", or "unique control of the name+email pair".
Sizes are also manageable. For $70, you can fit the entire index in RAM.