Re: Data Warehouse Reevaluation - MySQL vs Postgres --

Поиск
Список
Период
Сортировка
От Stephen Frost
Тема Re: Data Warehouse Reevaluation - MySQL vs Postgres --
Дата
Msg-id 20040914143303.GR21419@ns.snowman.net
обсуждение исходный текст
Ответ на Re: Data Warehouse Reevaluation - MySQL vs Postgres --  (Markus Schaber <schabios@logi-track.com>)
Ответы Re: Data Warehouse Reevaluation - MySQL vs Postgres --  ("Simon Riggs" <simon@2ndquadrant.com>)
Re: Data Warehouse Reevaluation - MySQL vs Postgres --  (Mischa Sandberg <ischamay.andbergsay@activestateway.com>)
Список pgsql-performance
* Markus Schaber (schabios@logi-track.com) wrote:
> Generally, what is the fastest way for doing bulk processing of
> update-if-primary-key-matches-and-insert-otherwise operations?

This is a very good question, and I havn't seen much of an answer to it
yet.  I'm curious about the answer myself, actually.  In the more recent
SQL specs, from what I understand, this is essentially what the 'MERGE'
command is for.  This was recently added and unfortunately is not yet
supported in Postgres.  Hopefully it will be added soon.

Otherwise, what I've done is basically an update followed by an insert
using outer joins.  If there's something better, I'd love to hear about
it.  The statements looks something like:

update X
  set colA = a.colA,
      colB = a.colB
  from Y a
  where keyA = a.keyA and
        keyB = a.keyB;

insert into X
  select a.keyA,
         a.keyB,
     a.colA,
     a.colB
  from Y a left join X b
       using (keyA, keyB)
  where b.keyA is NULL and
        b.keyB is NULL;

With the appropriate indexes, this is pretty fast but I think a merge
would be much faster.

        Thanks,

            Stephen

Вложения

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

Предыдущее
От: Michael Kleiser
Дата:
Сообщение: Re: Data Warehouse Reevaluation - MySQL vs Postgres --
Следующее
От: "Harald Lau (Sector-X)"
Дата:
Сообщение: Re: Data Warehouse Reevaluation - MySQL vs Postgres -- merge tables