Re: Deleting orphaned records (not exists is very slow)

Поиск
Список
Период
Сортировка
От Michael Glaesemann
Тема Re: Deleting orphaned records (not exists is very slow)
Дата
Msg-id 297FDC28-6CC4-4A8D-B98A-D42370C16BD8@seespotcode.net
обсуждение исходный текст
Ответ на Re: Deleting orphaned records (not exists is very slow)  (Tim Uckun <timuckun@gmail.com>)
Список pgsql-general
On Sep 27, 2010, at 23:20 , Tim Uckun wrote:

>> Why are you messing with ctid? Does the table have no key? If not, you should fix that first.
>>
>
> I got the idea from here
>
> http://www.postgres.cz/index.php/PostgreSQL_SQL_Tricks

If your table already has a key (some column or combination of columns that is unique per row),
there's really no need to use ctid. The only reason they're using ctid on that page because
they have duplicate rows: the table *doesn't* have a key and they have no other way to specify
rows uniquely. Given you reference an id column, I suspect your your table already has a key,
so you should just use that.

ctid is an implementation detail of PostgreSQL rather than part of the logical design of the
database: it really shouldn't be used unless you absolutely have to.

Anyway, sounds like you got it sussed out. Good luck with straightening out the rest of your data!

Michael Glaesemann
grzm seespotcode net




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

Предыдущее
От: Tim Uckun
Дата:
Сообщение: Re: Killing "stuck" queries and preventing queries from getting "stuck"
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: Preserving order through an inner join