how to deal with sparse/to-be populated tables

Поиск
Список
Период
Сортировка
От Alfred Perlstein
Тема how to deal with sparse/to-be populated tables
Дата
Msg-id 20000203145401.O25520@fw.wintelcom.net
обсуждение исходный текст
Список pgsql-hackers
We were having some trouble doing updates to our database,
a lot of our database sort of works like this:


dbfunc(data) somedatatype    *data;
{somedatatype    *existing_row;
existing_row = exists_in_table(data);
if (existing_row != NULL) {    update_table(existing_row, count = count + data->count)} else
insert_into_table(data);

}

Is there anything built into postgresql to accomplish this without
the "double" work that goes on here?

something like: update_row_but_insert_if_it_doesn't_exist(data,    update = 'count = count + data->count');

Meaning, if a row matching the 'new' data exists, update it, otherwise
store our new data as a new record?

It seems like the database has to do an awful amount of extra work
for our application because we haven't figured out how to do this
effeciently.

Any pointers?

thanks,
-- 
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]


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

Предыдущее
От: "Oliver Elphick"
Дата:
Сообщение: Re: [INTERFACES] coming ColdFusion support for PostgreSQL
Следующее
От: Hannu Krosing
Дата:
Сообщение: Re: [HACKERS] Re: [SQL] Proposed Changes to PostgreSQL