Import large data set into a table and resolve duplicates?

Поиск
Список
Период
Сортировка
От Eugene Dzhurinsky
Тема Import large data set into a table and resolve duplicates?
Дата
Msg-id 20150214173744.GA13063@devbox
обсуждение исходный текст
Список pgsql-general
Hello!

I have a huge dictionary table with series data generated by a third-party
service. The table consists of 2 columns

- id : serial, primary key
- series : varchar, not null, indexed

From time to time I need to apply a "patch" to the dictionary, the patch file
consists of "series" data, one per line.

Now I need to import the patch into the database, and produce another file as
- if the passed "series" field exists in the database, then return ID:series
- otherwise insert a new row to the table and generate new ID and return ID:series
for each row in the source file.

So the new file will contain both ID and series data, separated by tab or
something.

While reading and writing the data is not a question (I simply described the
whole task just in case), I wonder what is the most efficient way of importing
such a data into a table, keeping in mind that

- the dictionary table already consists of ~200K records
- the patch could be ~1-50K of records long

Thanks!

--
Eugene N Dzhurinsky

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: Ramesh T
Дата:
Сообщение: Re: dbmsscheduler
Следующее
От: Ramesh T
Дата:
Сообщение: Re: postgres cust types