Re: ask for review of MERGE
От | Robert Haas |
---|---|
Тема | Re: ask for review of MERGE |
Дата | |
Msg-id | AANLkTimZk5ywU7QbfWrPyTaaqpYvbnmXogHJuOwiq6gE@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: ask for review of MERGE (Martijn van Oosterhout <kleptog@svana.org>) |
Ответы |
Re: ask for review of MERGE
|
Список | pgsql-hackers |
On Sun, Oct 24, 2010 at 5:50 AM, Martijn van Oosterhout <kleptog@svana.org> wrote: > On Sat, Oct 23, 2010 at 03:59:13PM -0700, Greg Stark wrote: >> I think the blocker with MERGE has always been that the standard is >> *so* general that it could apply to conditions that *aren't* covered >> by a unique constraint or exclusion constriant. Personally, I'm fine >> saying that those cases will perform poorly, locking the table, or >> aren't allowed and print a warning explaining exactly what exclusion >> constraint or btree unique index would be necessary to allow it. I >> think virtually every case where people will want to use it will be on >> a primary key anyways. > > Can we please not get MERGE hung up on trying to make it atomic. The > standard requires no such thing and there are plenty of uses of MERGE > that don't involve high concurrency updates of the same row by > different processes. If we want an atomic UPSERT, make that a seperate > command, MERGE without atomicity is useful enough already. > > Simply, if the row is visible in the current snapshot you do an update > otherwise an insert. If you get an error, raise it. Icing can be added > later. Long term, I'm wondering if the permanent fix for this problem might involve something similar to what EXCLUDE does - use a dirty snapshot for the scan of the target table, and block on in=d Yeah, I couldn't have said it better. It's an annoying implementation restriction but only that. I think it's a perfectly acceptable restriction for an initial commit. It's no secret that our process has trouble absorbing large patches. I am also wondering exactly what the semantics are supposed to be under concurrency. We can't assume that it's OK to treat WHEN NOT MATCHED as WHEN MATCHED if a unique-key violation is encountered. The join condition could be something else entirely. I guess we could scan the target table with a dirty snapshot and block on any in-doubt tuples, similar to what EXCLUDE constraints do internally, but throwing MVCC out the window doesn't seem right either. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
В списке pgsql-hackers по дате отправления: