Re: [GENERAL] Dealing with ordered hierarchies

Поиск
Список
Период
Сортировка
От Peter J. Holzer
Тема Re: [GENERAL] Dealing with ordered hierarchies
Дата
Msg-id 20170731201100.GE29214@hjp.at
обсуждение исходный текст
Ответ на Re: [GENERAL] Dealing with ordered hierarchies  (Tim Uckun <timuckun@gmail.com>)
Список pgsql-general
On 2017-07-25 01:15:56 +1200, Tim Uckun wrote:
> I don't like the approach with a large increment. It would mean complicated
> logic to see if you filled the gap and then update all the other peers if you
> did. It sounds like the re-order is going to be expensive no matter what. My
> primary concern are race conditions though. What if two or more users are
> trying to update the hierarchy either by inserts or updates? I can definitely
> see a situation where we have issues transactions trip over each other.

You could add a unique index over (parent, sequence_number). That way
two transactions won't be able to add a node with the same sequence
number under the same parent. You will have to handle duplicate key
errors, though.

        hp

--
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp@hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>

Вложения

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

Предыдущее
От: Dmitry Lazurkin
Дата:
Сообщение: Re: [GENERAL] Perfomance of IN-clause with many elements and possiblesolutions
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [GENERAL] Partitioned TEMP tables