Answer the question
In order to leave comments, you need to log in
How to set up auto-increment in sqlite so that it increments after a condition is met?
There is a large database in which there is only one table (table name: main), in which there are two attributes - user_id (integer) and id (primary key) and 14 million records.
Every day, another 3 million records are added to this database, on average, but only those user_ids that are not yet in the database should be inserted. From 3 million there are somewhere around 500k records. This happens every day.
Thus, every day in the database where there are already 14 million records, another 3 million will be inserted, of which 2.5 million are already there and they should be ignored, and only 500k should end up, which are not in the database yet. In addition, I then need to get these 500k records in order to find out which specific 500k are not yet in the database.
I used to do it through notepad ++, but the computer is no longer capable of 6 million records, I had to switch to the database.
I think that the most reasonable way to do it is this:
1) First look at the maximum id, remember it.
2) use INSERT OR IGNORE and insert 3 million records.
3)select user_id from main where id>idishnik from the first point.
when I use INSERT OR IGNORE, although identical records are not added, the id is incremented anyway. And it turns out that every day 2.5 million records that are already in the database will increment id by these 2.5 million. It seems to me that the day will come when id will not be able to increase anymore. Therefore, I want the id to increase each time by as much as the number of records actually inserted.
How to do it?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question