Re: logical column ordering

Поиск
Список
Период
Сортировка
От Tomas Vondra
Тема Re: logical column ordering
Дата
Msg-id 54F0D2B8.40203@2ndquadrant.com
обсуждение исходный текст
Ответ на Re: logical column ordering  (Josh Berkus <josh@agliodbs.com>)
Список pgsql-hackers
On 27.2.2015 21:09, Josh Berkus wrote:
> Tomas,
> 
> So for an API, 100% of the use cases I have for this feature would be
> satisfied by:
> 
> ALTER TABLE ______ ALTER COLUMN _____ SET ORDER #
> 
> and:
> 
> ALTER TABLE _____ ADD COLUMN colname coltype ORDER #

Yes, I imagined an interface like that. Just to be clear, you're talking
about logical order (and not a physical one), right?

Do we need an API to modify physical column order? (I don't think so.)


> If that's infeasible, a function would be less optimal, but would work:
> 
> SELECT pg_column_order(schemaname, tablename, colname, attnum)

If we need a user interface, let's have a proper one (ALTER TABLE).


> If you set the order # to one where a column already exists, other 
> column attnums would get "bumped down", closing up any gaps in the 
> process. Obviously, this would require some kind of exclusive lock,
> but then ALTER TABLE usually does, doesn't it?

If we ignore the system columns, the current implementation assumes that
the values in each of the three columns (attnum, attlognum and
attphysnum) are distinct and within 1..natts. So there are no gaps and
you'll always set the value to an existing one (so yes, shuffling is
necessary).

And yes, that certainly requires an exclusive lock on the pg_attribute
(I don't think we need a lock on the table itself).

-- 
Tomas Vondra                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



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

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: Re: logical column ordering
Следующее
От: Gavin Flower
Дата:
Сообщение: Re: logical column ordering