Re: Column storage positions

Lists: pgsql-hackers
From: "Phil Currier" <pcurrier(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Column storage positions
Date: 2007-02-20 21:07:43
Message-ID: c58979e50702201307w64b12892uf8dfc3d8bf117ec0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Inspired by this thread [1], and in particular by the idea of storing
three numbers (permanent ID, on-disk storage position, display
position) for each column, I spent a little time messing around with a
prototype implementation of column storage positions to see what kind
of difference it would make. The results were encouraging: on a table
with 20 columns of alternating smallint and varchar(10) datatypes,
selecting the max() of one of the rightmost int columns across 1
million rows ran around 3 times faster. The same query on the
leftmost varchar column (which should suffer the most from this
change) predictably got a little slower (about 10%); I couldn't
measure a performance drop on the rightmost varchar columns. The
table's size didn't drop much in this case, but a different table of
20 alternating int and smallint columns showed a 20% slimmer disk
footprint, pretty much as expected. Pgbenching showed no measurable
difference, which isn't surprising since the pgbench test tables
consist of just int values with char filler at the end.

So here is a proposal for separating a column's storage position from
its permanent ID. I've ignored the display position piece of the
original thread because display positions don't do much other than
save you the hassle of creating a view on top of your table, while
storage positions have demonstrable, tangible benefits. And there is
no reason to connect the two features; display positions can easily be
added separately at a later point.

We want to decouple a column's on-disk storage position from its
permanent ID for two reasons: to minimize the space lost to alignment
padding between fields, and to speed up access to individual fields.
The system will automatically assign new storage positions when a
table is created, and when a table alteration requires a rewrite
(currently just adding a column with a default, or changing a column
datatype). To allow users to optimize tables based on the fields they
know will be frequently accessed, I think we should extend ALTER TABLE
to accept user-assigned storage positions (something like "ALTER TABLE
ALTER col SET STORAGE POSITION X"). This command would also be useful
for another reason discussed below.

In my prototype, I used these rules to determine columns' storage order:
1) fixed-width fields before variable-width, dropped columns always last
2) fixed-width fields ordered by increasing size
3) not-null fields before nullable fields
There are other approaches worth considering - for example, you could
imagine swapping the priority of rules 2 and 3. Resultant tables
would generally have more alignment waste, but would tend to have
slightly faster field access. I'm really not sure what the optimal
strategy is since every user will have a slightly different metric for
"optimal". In any event, either of these approaches is better than
the current situation.

To implement this, we'll need a field (perhaps attstoragepos?) in
pg_attribute to hold the storage position. It will equal attnum until
it is explicitly reassigned. The routines in heaptuple.c need to
quickly loop through the fields of a tuple in storage order rather
than attnum order, so I propose extending TupleDesc to hold an
"attrspos" array that sits alongside the attrs array. In the
prototype I used an array of int2 indices into the attrs array,
ordered by storage position.

These changes cause a problem in ExecTypeFromTLInternal: this function
calls CreateTemplateTupleDesc followed by TupleDescInitEntry, assuming
that attnum == attstoragepos for all tuples. With the introduction of
storage positions, this of course will no longer be true. I got
around this by having expand_targetlist, build_physical_tlist, and
build_relation_tlist make sure each TargetEntry (for targetlists
corresponding to either insert/update tuples, or base tuples pulled
straight from the heap) gets a correct resorigtbl and resname. Then
ExecTypeFromTLInternal first tries calling a new function
TupleDescInitEntryAttr, which hands off to TupleDescInitEntry and then
performs a syscache lookup to update the storage position using the
resorigtbl. This is a little ugly because ExecTypeFromTLInternal
doesn't know in advance what kind of tupledesc it's building, so it
needs to retreat to the old method whenever the syscache lookup fails,
but it was enough to pass the regression tests. I could use some
advice on this - there's probably a better way to do it.

Another problem relates to upgrades. With tools like pg_migrator now
on pgfoundry, people will eventually expect quick upgrades that don't
require rewriting each table's data. Storage positions would cause a
problem for every version X -> version Y upgrade with Y >= 8.3, even
when X is also >= 8.3, because a version X table could always have
been altered without a rewrite into a structure different from what
Y's CREATE TABLE will choose. I don't think it's as simple as just
using the above-mentioned ALTER TABLE extension to assign the proper
storage positions for each field, because the version X table could
have dropped columns that might or might not be present in any given
tuple on disk. The best solution I can see is having pg_dump create a
table covering *all* columns (including dropped ones) with explicit
storage positions, and then immediately issue an alter statement to
get rid of the dropped columns. I'm not thrilled about this approach
(in particular, preserving dropped columns across upgrades seems
sloppy), but I haven't been able to think of anything better.
Hopefully I'm missing a simpler way to do this.

Comments and ideas? Does this whole thing seem worthwhile to do?

phil

[1] http://archives.postgresql.org/pgsql-hackers/2006-12/msg00780.php


From: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
To: Phil Currier <pcurrier(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-20 22:04:32
Message-ID: Pine.LNX.4.64.0702210042030.3994@lnfm1.sai.msu.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Just as my 2 cents to the proposed idea.
I want to demonstrate that the proposed idea is very relevant for the
performance.

I recently did an migration from PG 8.1 to PG 8.2. During that time I was
dumping the 2TB database with several very wide tables (having ~ 200
columns). And I saw that on my pretty powerful server with 8Gb
RAM, Itanium2 procesor,large RAID which can do I/O at 100Mb/sec the
performance of pg_dump was CPU limited, and the read speed of the tables
was 1-1.5mb/sec (leading to 2 week dumping time).

I was very surprised by these times, and profiled postgres to check the
reason of that:
here is the top of gprof:
% cumulative self self total
time seconds seconds calls s/call s/call name
60.72 13.52 13.52 6769826 0.00 0.00 nocachegetattr
10.58 15.88 2.36 9035566 0.00 0.00 CopyAttributeOutText
7.22 17.49 1.61 65009457 0.00 0.00 CopySendData
6.34 18.90 1.41 1 1.41 22.21 CopyTo

So the main slow-down of the process was all this code recomputing the
boundaries of the columns.... I checked that by removing one tiny varchar
column and COALESCING all NULLs, and after that the performance of
pg_dumping increased by more than a factor of 2!

I should have reported that experience earlier... but I hope that my
observations can be useful in the context of the Phil's idea.

regards,
Sergey

*******************************************************************
Sergey E. Koposov
Max Planck Institute for Astronomy/Cambridge Institute for Astronomy/Sternberg Astronomical Institute
Tel: +49-6221-528-349
Web: http://lnfm1.sai.msu.ru/~math
E-mail: math(at)sai(dot)msu(dot)ru


From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Cc: "Phil Currier" <pcurrier(at)gmail(dot)com>
Subject: Re: Column storage positions
Date: 2007-02-21 00:54:42
Message-ID: 200702201954.42880.xzilla@users.sourceforge.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tuesday 20 February 2007 16:07, Phil Currier wrote:
> Another problem relates to upgrades. With tools like pg_migrator now
> on pgfoundry, people will eventually expect quick upgrades that don't
> require rewriting each table's data. Storage positions would cause a
> problem for every version X -> version Y upgrade with Y >= 8.3, even
> when X is also >= 8.3, because a version X table could always have
> been altered without a rewrite into a structure different from what
> Y's CREATE TABLE will choose.

If you are using pg_migrator your not going to be moving the datafiles on disk
anyway,so pg_migrator's behavior shouldnt change terribly. If your doing
pg_dump based upgrade, presumably pg_dump could write it's create statements
with the columns in attstorpos order and set attnum = attstorpos, preserving
the physical layout from the previous install.

--
Robert Treat
Build A Brighter LAMP :: Linux Apache {middleware} PostgreSQL


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Phil Currier <pcurrier(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 13:54:07
Message-ID: 20070221135407.GL25424@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Phil Currier escribió:
> Inspired by this thread [1], and in particular by the idea of storing
> three numbers (permanent ID, on-disk storage position, display
> position) for each column, I spent a little time messing around with a
> prototype implementation of column storage positions to see what kind
> of difference it would make. The results were encouraging: on a table
> with 20 columns of alternating smallint and varchar(10) datatypes,
> selecting the max() of one of the rightmost int columns across 1
> million rows ran around 3 times faster.

[snipped]

I'd expect the system being able to reoder the columns to the most
efficient order possible (performance-wise and padding-saving-wise),
automatically. When you create a table, sort the columns to the most
efficient order; ALTER TABLE ADD COLUMN just puts the new columns at the
end of the tuple; and anything that requires a rewrite of the table
(ALTER TABLE ... ALTER TYPE for example; would be cool to have CLUSTER
do it as well; and do it on TRUNCATE also) again recomputes the most
efficient order.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: "Phil Currier" <pcurrier(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 14:25:09
Message-ID: c58979e50702210625m677291e8x8836a0d1b9fb9de5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2/21/07, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
> I'd expect the system being able to reoder the columns to the most
> efficient order possible (performance-wise and padding-saving-wise),
> automatically. When you create a table, sort the columns to the most
> efficient order; ALTER TABLE ADD COLUMN just puts the new columns at the
> end of the tuple; and anything that requires a rewrite of the table
> (ALTER TABLE ... ALTER TYPE for example; would be cool to have CLUSTER
> do it as well; and do it on TRUNCATE also) again recomputes the most
> efficient order.

That's exactly what I'm proposing. On table creation, the system
chooses an efficient column order for you. The next time an ALTER
TABLE operation forces a rewrite, the system would recompute the
column storage order. I hadn't thought of having CLUSTER also redo
the storage order, but that seems safe since it takes an exclusive
lock on the table. I'm less sure about whether it's safe to do this
during a TRUNCATE.

phil


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Phil Currier <pcurrier(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 14:55:52
Message-ID: 200702211455.l1LEtq803457@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Phil Currier wrote:
> On 2/21/07, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
> > I'd expect the system being able to reoder the columns to the most
> > efficient order possible (performance-wise and padding-saving-wise),
> > automatically. When you create a table, sort the columns to the most
> > efficient order; ALTER TABLE ADD COLUMN just puts the new columns at the
> > end of the tuple; and anything that requires a rewrite of the table
> > (ALTER TABLE ... ALTER TYPE for example; would be cool to have CLUSTER
> > do it as well; and do it on TRUNCATE also) again recomputes the most
> > efficient order.
>
> That's exactly what I'm proposing. On table creation, the system
> chooses an efficient column order for you. The next time an ALTER
> TABLE operation forces a rewrite, the system would recompute the
> column storage order. I hadn't thought of having CLUSTER also redo
> the storage order, but that seems safe since it takes an exclusive
> lock on the table. I'm less sure about whether it's safe to do this
> during a TRUNCATE.

Keep in mind we have a patch in process to reduce the varlena length and
reduce alignment requirements, so once that is in, reordering columns
will not be as important.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Phil Currier <pcurrier(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 14:59:12
Message-ID: 45DC5E40.6070203@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Phil Currier wrote:
> On 2/21/07, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
>> I'd expect the system being able to reoder the columns to the most
>> efficient order possible (performance-wise and padding-saving-wise),
>> automatically. When you create a table, sort the columns to the most
>> efficient order; ALTER TABLE ADD COLUMN just puts the new columns at the
>> end of the tuple; and anything that requires a rewrite of the table
>> (ALTER TABLE ... ALTER TYPE for example; would be cool to have CLUSTER
>> do it as well; and do it on TRUNCATE also) again recomputes the most
>> efficient order.
>
> That's exactly what I'm proposing. On table creation, the system
> chooses an efficient column order for you. The next time an ALTER
> TABLE operation forces a rewrite, the system would recompute the
> column storage order. I hadn't thought of having CLUSTER also redo
> the storage order, but that seems safe since it takes an exclusive
> lock on the table. I'm less sure about whether it's safe to do this
> during a TRUNCATE.

I think you'd want to have a flag per field that tell you if the user
has overridden the storage pos for that specific field. Otherwise,
the next time you have to chance to optimize the ordering, you might
throw away changes that the admin has done on purpose. The same hold
true for a pg_dump/pg_reload cycle. If none of the fields had their
storage order changed manually, you'd want to reoder them optimally
at dump/reload time. If, however, the admin specified an ordering, you'd
want to preserve that.

greetings, Florian Pflug


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Phil Currier <pcurrier(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 15:28:49
Message-ID: 20070221152849.GR25424@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian escribió:
> Phil Currier wrote:
> > On 2/21/07, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
> > > I'd expect the system being able to reoder the columns to the most
> > > efficient order possible (performance-wise and padding-saving-wise),
> > > automatically. When you create a table, sort the columns to the most
> > > efficient order; ALTER TABLE ADD COLUMN just puts the new columns at the
> > > end of the tuple; and anything that requires a rewrite of the table
> > > (ALTER TABLE ... ALTER TYPE for example; would be cool to have CLUSTER
> > > do it as well; and do it on TRUNCATE also) again recomputes the most
> > > efficient order.
> >
> > That's exactly what I'm proposing. On table creation, the system
> > chooses an efficient column order for you. The next time an ALTER
> > TABLE operation forces a rewrite, the system would recompute the
> > column storage order. I hadn't thought of having CLUSTER also redo
> > the storage order, but that seems safe since it takes an exclusive
> > lock on the table. I'm less sure about whether it's safe to do this
> > during a TRUNCATE.
>
> Keep in mind we have a patch in process to reduce the varlena length and
> reduce alignment requirements, so once that is in, reordering columns
> will not be as important.

Yes, but the "cache offset" stuff is still significant, so there will be
some benefit in putting all the fixed-length attributes at the start of
the tuple, and varlena atts grouped at the end.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: "Phil Currier" <pcurrier(at)gmail(dot)com>
To: "Bruce Momjian" <bruce(at)momjian(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 15:29:45
Message-ID: c58979e50702210729v61aa1e8bk15cb67c7a8c56890@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2/21/07, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> Keep in mind we have a patch in process to reduce the varlena length and
> reduce alignment requirements, so once that is in, reordering columns
> will not be as important.

Well, as I understand it, that patch isn't really addressing the same
problem. Consider this table:
create table foo (a varchar(10), b int, c smallint, d int, e smallint, ....);

There are two problems here:

1) On my machine, each int/smallint column pair takes up 8 bytes. 2
of those 8 bytes are alignment padding wasted on the smallint field.
If we grouped all the smallint fields together within the tuple, that
space would not be lost.

2) Each time you access any of the int/smallint fields, you have to
peek inside the varchar field to figure out its length. If we stored
the varchar field at the end of the tuple instead, the access times
for all the other fields would be measurably improved, by a factor
that greatly outweighs the small penalty imposed on the varchar field
itself.

My understanding is that the varlena headers patch would potentially
reduce the size of the varchar header (which is definitely worthwhile
by itself), but it wouldn't help much for either of these problems.
Or am I misunderstanding what that patch does?

phil


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Phil Currier <pcurrier(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 15:33:26
Message-ID: 200702211533.l1LFXQT04510@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera wrote:
> Bruce Momjian escribi?:
> > Phil Currier wrote:
> > > On 2/21/07, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
> > > > I'd expect the system being able to reoder the columns to the most
> > > > efficient order possible (performance-wise and padding-saving-wise),
> > > > automatically. When you create a table, sort the columns to the most
> > > > efficient order; ALTER TABLE ADD COLUMN just puts the new columns at the
> > > > end of the tuple; and anything that requires a rewrite of the table
> > > > (ALTER TABLE ... ALTER TYPE for example; would be cool to have CLUSTER
> > > > do it as well; and do it on TRUNCATE also) again recomputes the most
> > > > efficient order.
> > >
> > > That's exactly what I'm proposing. On table creation, the system
> > > chooses an efficient column order for you. The next time an ALTER
> > > TABLE operation forces a rewrite, the system would recompute the
> > > column storage order. I hadn't thought of having CLUSTER also redo
> > > the storage order, but that seems safe since it takes an exclusive
> > > lock on the table. I'm less sure about whether it's safe to do this
> > > during a TRUNCATE.
> >
> > Keep in mind we have a patch in process to reduce the varlena length and
> > reduce alignment requirements, so once that is in, reordering columns
> > will not be as important.
>
> Yes, but the "cache offset" stuff is still significant, so there will be
> some benefit in putting all the fixed-length attributes at the start of
> the tuple, and varlena atts grouped at the end.

Agreed.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Phil Currier <pcurrier(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 15:34:02
Message-ID: 200702211534.l1LFY2P04574@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Phil Currier wrote:
> On 2/21/07, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> > Keep in mind we have a patch in process to reduce the varlena length and
> > reduce alignment requirements, so once that is in, reordering columns
> > will not be as important.
>
> Well, as I understand it, that patch isn't really addressing the same
> problem. Consider this table:
> create table foo (a varchar(10), b int, c smallint, d int, e smallint, ....);
>
> There are two problems here:
>
> 1) On my machine, each int/smallint column pair takes up 8 bytes. 2
> of those 8 bytes are alignment padding wasted on the smallint field.
> If we grouped all the smallint fields together within the tuple, that
> space would not be lost.

Yes, good point.

> 2) Each time you access any of the int/smallint fields, you have to
> peek inside the varchar field to figure out its length. If we stored
> the varchar field at the end of the tuple instead, the access times
> for all the other fields would be measurably improved, by a factor
> that greatly outweighs the small penalty imposed on the varchar field
> itself.
>
> My understanding is that the varlena headers patch would potentially
> reduce the size of the varchar header (which is definitely worthwhile
> by itself), but it wouldn't help much for either of these problems.
> Or am I misunderstanding what that patch does?
>

Agreed.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
Cc: Phil Currier <pcurrier(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 16:04:38
Message-ID: 20070221160438.GD30975@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Feb 21, 2007 at 03:59:12PM +0100, Florian G. Pflug wrote:
> I think you'd want to have a flag per field that tell you if the user
> has overridden the storage pos for that specific field. Otherwise,
> the next time you have to chance to optimize the ordering, you might
> throw away changes that the admin has done on purpose.

Why would you want to let the admin have any say at all about the
storage order?

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
Cc: Phil Currier <pcurrier(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 16:22:26
Message-ID: 45DC71C2.2090400@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Florian G. Pflug wrote:
>
> I think you'd want to have a flag per field that tell you if the user
> has overridden the storage pos for that specific field. Otherwise,
> the next time you have to chance to optimize the ordering, you might
> throw away changes that the admin has done on purpose. The same hold
> true for a pg_dump/pg_reload cycle. If none of the fields had their
> storage order changed manually, you'd want to reoder them optimally
> at dump/reload time. If, however, the admin specified an ordering, you'd
> want to preserve that.
>

I don't think users should be monkeying with the storage position at
all. Decisions about that should belong to the engine, not to users.
Providing a user tweakable knob for this strikes me as a large footgun,
as well as requiring all sorts of extra checks along the lines you are
talking of.

cheers

andrew


From: "Phil Currier" <pcurrier(at)gmail(dot)com>
To: "Martijn van Oosterhout" <kleptog(at)svana(dot)org>
Cc: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 17:06:30
Message-ID: c58979e50702210906m71020d83hffa2af7db08a4b17@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2/21/07, Martijn van Oosterhout <kleptog(at)svana(dot)org> wrote:
> On Wed, Feb 21, 2007 at 03:59:12PM +0100, Florian G. Pflug wrote:
> > I think you'd want to have a flag per field that tell you if the user
> > has overridden the storage pos for that specific field. Otherwise,
> > the next time you have to chance to optimize the ordering, you might
> > throw away changes that the admin has done on purpose.
>
> Why would you want to let the admin have any say at all about the
> storage order?

Well, for two reasons:

1) If you have a table with one very-frequently-accessed varchar()
column and several not-frequently-accessed int columns, it might
actually make sense to put the varchar column first. The system won't
always be able to make the most intelligent decision about table
layout.

2) As I described in my original email, without this capability, I
don't see any good way to perform an upgrade between PG versions
without rewriting each table's data. Maybe most people aren't doing
upgrades like this right now, but it seems like it will only become
more common in the future. In my opinion, this is more important than
#1.

But I understand that it's a potential foot-gun, so I'm happy to drop
it. It would be nice though if there were some ideas about how to
address problem #2 at least.

phil


From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Phil Currier <pcurrier(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 17:17:30
Message-ID: 45DC7EAA.3080002@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Martijn van Oosterhout wrote:
> On Wed, Feb 21, 2007 at 03:59:12PM +0100, Florian G. Pflug wrote:
>> I think you'd want to have a flag per field that tell you if the user
>> has overridden the storage pos for that specific field. Otherwise,
>> the next time you have to chance to optimize the ordering, you might
>> throw away changes that the admin has done on purpose.
>
> Why would you want to let the admin have any say at all about the
> storage order?

It wasn't my idea - the OP proposed a "alter table <table> alter column
<col> set storage position <pos>" command. But if you're gonna decouple
the storage order from the attnum, they why don't let the dba tweak it?

Since you have at least two possible optimization speeds - for size, or
for fast access to specifc fields, creating a one-size-fits-all ordering
rule seems hard...

greetings, Florian Pflug


From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Phil Currier <pcurrier(at)gmail(dot)com>
Cc: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 17:20:19
Message-ID: 20070221172019.GE30975@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Feb 21, 2007 at 12:06:30PM -0500, Phil Currier wrote:
> Well, for two reasons:
>
> 1) If you have a table with one very-frequently-accessed varchar()
> column and several not-frequently-accessed int columns, it might
> actually make sense to put the varchar column first. The system won't
> always be able to make the most intelligent decision about table
> layout.

Umm, the point of the exercise is that if you know there are int
columns, then you can skip over them, whereas you can never skip over a
varchar column. So there isn't really any situation where it would be
better to put the varchar first.

>
> don't see any good way to perform an upgrade between PG versions
> without rewriting each table's data. Maybe most people aren't doing
> upgrades like this right now, but it seems like it will only become
> more common in the future. In my opinion, this is more important than
> #1.

I don't see this either. For all current tables, the storage position
is the attribute number, no exception. You say:

> because the version X table could
> have dropped columns that might or might not be present in any given
> tuple on disk.

Whether they're there or not is irrelevent. Drop columns are not
necesarily empty, but in any case they occupy a storage position until
the table is rewritten. A dump/restore doesn't need to preserve this,
but pg_migrator will need some smarts to handle it. The system will
need to create a column of the appropriate type and drop it to get to
the right state.

If you really want to use pg_dump I'd suggest an option to pg_dump
--dump-dropped-columns which will include the dropped columns in the
CREATE TABLE but drop them immediatly after. It's really more a corner
case than anything else.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.


From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Phil Currier <pcurrier(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 17:20:49
Message-ID: 45DC7F71.7060809@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan wrote:
> Florian G. Pflug wrote:
>>
>> I think you'd want to have a flag per field that tell you if the user
>> has overridden the storage pos for that specific field. Otherwise,
>> the next time you have to chance to optimize the ordering, you might
>> throw away changes that the admin has done on purpose. The same hold
>> true for a pg_dump/pg_reload cycle. If none of the fields had their
>> storage order changed manually, you'd want to reoder them optimally
>> at dump/reload time. If, however, the admin specified an ordering, you'd
>> want to preserve that.
>>
>
> I don't think users should be monkeying with the storage position at
> all. Decisions about that should belong to the engine, not to users.
> Providing a user tweakable knob for this strikes me as a large footgun,
> as well as requiring all sorts of extra checks along the lines you are
> talking of.

Maybe you shouldn't support specifying the storage order directly, but
rather through some kind of "priority field". The idea would be that
the storage order is determinted by sorting the fields according to
the priority field. Groups of fields with the same priority would
get ordered for maximal space efficiency.

greetings, Florian Pflug


From: "Simon Riggs" <simon(at)2ndquadrant(dot)com>
To: "Phil Currier" <pcurrier(at)gmail(dot)com>, "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Column storage positions
Date: 2007-02-21 17:59:50
Message-ID: 1172080790.3874.35.camel@silverbirch.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, 2007-02-21 at 09:25 -0500, Phil Currier wrote:
> On 2/21/07, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
> > I'd expect the system being able to reoder the columns to the most
> > efficient order possible (performance-wise and padding-saving-wise),
> > automatically. When you create a table, sort the columns to the most
> > efficient order; ALTER TABLE ADD COLUMN just puts the new columns at the
> > end of the tuple; and anything that requires a rewrite of the table
> > (ALTER TABLE ... ALTER TYPE for example; would be cool to have CLUSTER
> > do it as well; and do it on TRUNCATE also) again recomputes the most
> > efficient order.
>
> That's exactly what I'm proposing. On table creation, the system
> chooses an efficient column order for you.

That's fairly straightforward and beneficial. I much prefer Alvaro's
approach rather than the storage position details originally described.
Moreover, you'd need to significantly re-write lots of ALTER TABLE and I
really don't think you want to go there.

There is a problem: If people do a CREATE TABLE and then issue SELECT *
they will find the columns in a different order. That could actually
break some programs, so it isn't acceptable in all cases. e.g. COPY
without a column-list assumes that the incoming data should be assigned
to the table columns in the same order as the incoming data file.

So if we do this, it should be controllable using a GUC:
optimize_column_order = off (default) | on
This should be a USERSET, so different users can create tables in either
full control or optimised mode, as they choose.

It should be possible to do that with the minimum number of position
swaps, so that people who have ordered the columns according to usage
frequency would still get what they wanted.

> The next time an ALTER
> TABLE operation forces a rewrite, the system would recompute the
> column storage order. I hadn't thought of having CLUSTER also redo
> the storage order, but that seems safe since it takes an exclusive
> lock on the table. I'm less sure about whether it's safe to do this
> during a TRUNCATE.

The GUC should apply to whenever/wherever this optimization occurs.

--
Simon Riggs
EnterpriseDB http://www.enterprisedb.com


From: "Phil Currier" <pcurrier(at)gmail(dot)com>
To: "Martijn van Oosterhout" <kleptog(at)svana(dot)org>
Cc: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 18:12:58
Message-ID: c58979e50702211012i2d3c1963j8b5aae1b50a68b6c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2/21/07, Martijn van Oosterhout <kleptog(at)svana(dot)org> wrote:
> > don't see any good way to perform an upgrade between PG versions
> > without rewriting each table's data. Maybe most people aren't doing
> > upgrades like this right now, but it seems like it will only become
> > more common in the future. In my opinion, this is more important than
> > #1.
>
> I don't see this either. For all current tables, the storage position
> is the attribute number, no exception. You say:
>
> > because the version X table could
> > have dropped columns that might or might not be present in any given
> > tuple on disk.
>
> Whether they're there or not is irrelevent. Drop columns are not
> necesarily empty, but in any case they occupy a storage position until
> the table is rewritten. A dump/restore doesn't need to preserve this,
> but pg_migrator will need some smarts to handle it. The system will
> need to create a column of the appropriate type and drop it to get to
> the right state.

I agree, a dump/restore that rewrites all the table datafiles doesn't
need to handle this. And I agree that the system will need to create
dropped columns and then drop them again, that's exactly what I
suggested in fact. We're talking about pg_migrator-style upgrades
only here.

Say we do this in 8.2:

create table foo (a varchar(10), b int);
insert into foo ....
alter table foo add column c int;

At this point, the column storage order is (a, b, c) because 8.2 never
changes storage order. Then you upgrade to 8.3. pg_dump now wants to
write out some DDL that will create a table matching the existing
table datafile, since we don't want to have to rewrite it. pg_dump
prints out:

create table foo (a varchar(10), b int, c int);

The 8.3 system will try to create the table with column order (b, c,
a), since it's trying to optimize storage order, and that won't match
the existing table datafile. What we need is a way to make sure that
the table matches the original datafile.

Now say that it's not an 8.2 -> 8.3 upgrade, say it's an 8.3 -> 8.4
upgrade. In this case, 8.3 would have the table with storage order
(b, a, c). (Column c would have been added at the end since it was
added without a default, and didn't force a table rewrite.) How do
you get pg_dump to print out table creation DDL that will result in a
table matching the existing (b, a, c) table datafile?

This is why I think pg_dump needs to be able to print an ALTER TABLE
statement that will explicitly assign storage positions. This happens
to have the side-effect of being potentially useful to admins who
might want control over that.

If this only affected 8.2 -> 8.3 upgrades, then maybe it's not as
important an issue. But I think it affects *all* future upgrades,
which is why I'm trying to raise the issue now.

> If you really want to use pg_dump I'd suggest an option to pg_dump
> --dump-dropped-columns which will include the dropped columns in the
> CREATE TABLE but drop them immediatly after. It's really more a corner
> case than anything else.


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Phil Currier <pcurrier(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 18:16:10
Message-ID: 45DC8C6A.4000605@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Simon Riggs wrote:
> On Wed, 2007-02-21 at 09:25 -0500, Phil Currier wrote:
>
>> On 2/21/07, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
>>
>>> I'd expect the system being able to reoder the columns to the most
>>> efficient order possible (performance-wise and padding-saving-wise),
>>> automatically. When you create a table, sort the columns to the most
>>> efficient order; ALTER TABLE ADD COLUMN just puts the new columns at the
>>> end of the tuple; and anything that requires a rewrite of the table
>>> (ALTER TABLE ... ALTER TYPE for example; would be cool to have CLUSTER
>>> do it as well; and do it on TRUNCATE also) again recomputes the most
>>> efficient order.
>>>
>> That's exactly what I'm proposing. On table creation, the system
>> chooses an efficient column order for you.
>>
>
> That's fairly straightforward and beneficial. I much prefer Alvaro's
> approach rather than the storage position details originally described.
> Moreover, you'd need to significantly re-write lots of ALTER TABLE and I
> really don't think you want to go there.
>
> There is a problem: If people do a CREATE TABLE and then issue SELECT *
> they will find the columns in a different order. That could actually
> break some programs, so it isn't acceptable in all cases. e.g. COPY
> without a column-list assumes that the incoming data should be assigned
> to the table columns in the same order as the incoming data file.
>

You seem to have missed that we will be separating logical from physical
ordering. Each attribute will have a permanent id, a physical ordering
and a logical ordering. You can change either ordering without affecting
the other.

COPY, SELECT and all user-visible commands should follow the logical
ordering, not the physical ordering, which should be completely
invisible to SQL.

cheers

andrew


From: "Simon Riggs" <simon(at)2ndquadrant(dot)com>
To: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
Cc: "Phil Currier" <pcurrier(at)gmail(dot)com>, "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Column storage positions
Date: 2007-02-21 18:39:48
Message-ID: 1172083189.3874.69.camel@silverbirch.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, 2007-02-21 at 13:16 -0500, Andrew Dunstan wrote:
> Simon Riggs wrote:
> > On Wed, 2007-02-21 at 09:25 -0500, Phil Currier wrote:
> >
> >> On 2/21/07, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
> >>
> >>> I'd expect the system being able to reoder the columns to the most
> >>> efficient order possible (performance-wise and padding-saving-wise),
> >>> automatically. When you create a table, sort the columns to the most
> >>> efficient order; ALTER TABLE ADD COLUMN just puts the new columns at the
> >>> end of the tuple; and anything that requires a rewrite of the table
> >>> (ALTER TABLE ... ALTER TYPE for example; would be cool to have CLUSTER
> >>> do it as well; and do it on TRUNCATE also) again recomputes the most
> >>> efficient order.
> >>>
> >> That's exactly what I'm proposing. On table creation, the system
> >> chooses an efficient column order for you.
> >>
> >
> > That's fairly straightforward and beneficial. I much prefer Alvaro's
> > approach rather than the storage position details originally described.
> > Moreover, you'd need to significantly re-write lots of ALTER TABLE and I
> > really don't think you want to go there.
> >
> > There is a problem: If people do a CREATE TABLE and then issue SELECT *
> > they will find the columns in a different order. That could actually
> > break some programs, so it isn't acceptable in all cases. e.g. COPY
> > without a column-list assumes that the incoming data should be assigned
> > to the table columns in the same order as the incoming data file.
> >
>
> You seem to have missed that we will be separating logical from physical
> ordering. Each attribute will have a permanent id, a physical ordering
> and a logical ordering. You can change either ordering without affecting
> the other.

I missed nothing, AFAICS. My understanding was that Alvaro was proposing
to have just a simple physical re-ordering and that would be altered at
CREATE TABLE time. No complexity of multiple column orderings: nice,
simple and effective. My only addition was to say: must be optional.

> COPY, SELECT and all user-visible commands should follow the logical
> ordering, not the physical ordering, which should be completely
> invisible to SQL.

I agree with comments here about the multiple orderings being a horrible
source of bugs, as well as lots of coding even to make it happen at all
http://archives.postgresql.org/pgsql-hackers/2006-12/msg00859.php

--
Simon Riggs
EnterpriseDB http://www.enterprisedb.com


From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Phil Currier <pcurrier(at)gmail(dot)com>, "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 19:27:05
Message-ID: 20070221111923.U81529@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, 21 Feb 2007, Martijn van Oosterhout wrote:

> On Wed, Feb 21, 2007 at 12:06:30PM -0500, Phil Currier wrote:
> > Well, for two reasons:
> >
> > 1) If you have a table with one very-frequently-accessed varchar()
> > column and several not-frequently-accessed int columns, it might
> > actually make sense to put the varchar column first. The system won't
> > always be able to make the most intelligent decision about table
> > layout.
>
> Umm, the point of the exercise is that if you know there are int
> columns, then you can skip over them, whereas you can never skip over a
> varchar column. So there isn't really any situation where it would be
> better to put the varchar first.

IIRC, in the first message in this thread, or another recent thread of
this type, someone tried a reordering example with alternating
smallints and varchar() and found that the leftmost varchar was
actually slower to access after reordering, so I'm not sure that we can
say there isn't a situation where it would affect things.


From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Phil Currier <pcurrier(at)gmail(dot)com>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 19:29:06
Message-ID: 45DC9D82.1040206@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Phil Currier wrote:
> On 2/21/07, Martijn van Oosterhout <kleptog(at)svana(dot)org> wrote:
>> > don't see any good way to perform an upgrade between PG versions
>> > without rewriting each table's data. Maybe most people aren't doing
>> > upgrades like this right now, but it seems like it will only become
>> > more common in the future. In my opinion, this is more important than
>> > #1.
>>
>> I don't see this either. For all current tables, the storage position
>> is the attribute number, no exception. You say:
>>
>> > because the version X table could
>> > have dropped columns that might or might not be present in any given
>> > tuple on disk.
>>
>> Whether they're there or not is irrelevent. Drop columns are not
>> necesarily empty, but in any case they occupy a storage position until
>> the table is rewritten. A dump/restore doesn't need to preserve this,
>> but pg_migrator will need some smarts to handle it. The system will
>> need to create a column of the appropriate type and drop it to get to
>> the right state.
>
> I agree, a dump/restore that rewrites all the table datafiles doesn't
> need to handle this. And I agree that the system will need to create
> dropped columns and then drop them again, that's exactly what I
> suggested in fact. We're talking about pg_migrator-style upgrades
> only here.

Why would a pg_migrator style upgrade use pg_dump at all? I assumed it
would rather copy the verbatim data from the old to the new catalog,
only changing it if the layout of the tables in pg_catalog actually
changed.

greetings, Florian Pflug


From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Phil Currier <pcurrier(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 19:33:10
Message-ID: 45DC9E76.7040108@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Simon Riggs wrote:
> On Wed, 2007-02-21 at 09:25 -0500, Phil Currier wrote:
>> On 2/21/07, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
>>> I'd expect the system being able to reoder the columns to the most
>>> efficient order possible (performance-wise and padding-saving-wise),
>>> automatically. When you create a table, sort the columns to the most
>>> efficient order; ALTER TABLE ADD COLUMN just puts the new columns at the
>>> end of the tuple; and anything that requires a rewrite of the table
>>> (ALTER TABLE ... ALTER TYPE for example; would be cool to have CLUSTER
>>> do it as well; and do it on TRUNCATE also) again recomputes the most
>>> efficient order.
>> That's exactly what I'm proposing. On table creation, the system
>> chooses an efficient column order for you.
>
> That's fairly straightforward and beneficial. I much prefer Alvaro's
> approach rather than the storage position details originally described.
> Moreover, you'd need to significantly re-write lots of ALTER TABLE and I
> really don't think you want to go there.
>
> There is a problem: If people do a CREATE TABLE and then issue SELECT *
> they will find the columns in a different order. That could actually
> break some programs, so it isn't acceptable in all cases. e.g. COPY
> without a column-list assumes that the incoming data should be assigned
> to the table columns in the same order as the incoming data file.

But the display order (and hence the COPY order) of columns would still
be determinted by attnum, not by some attstoragepos, no?
The column reordering would only apply to the physical storage of
columns, not to how it's presented to the user I'd think.

The original idea was to add a third column, attdisplaypos, and let the
user choose the display ordering independent from the unique id
(attnum), which in turn is independent from the storage position.

For simplicity, the OP said he omitted the display-position part here,
because it's really orthogonal to being able to modify the storage position.

greetings, Florian Pflug


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Phil Currier <pcurrier(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 19:35:44
Message-ID: 45DC9F10.20509@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Simon Riggs wrote:
>
> I agree with comments here about the multiple orderings being a horrible
> source of bugs, as well as lots of coding even to make it happen at all
> http://archives.postgresql.org/pgsql-hackers/2006-12/msg00859.php
>
>

I thought we were going with this later proposal of Tom's (on which he's
convinced me):
http://archives.postgresql.org/pgsql-hackers/2006-12/msg00983.php - if
not I'm totally confused (situation normal). The current thread started
with this sentence:

> Inspired by this thread [1], and in particular by the idea of storing
> three numbers (permanent ID, on-disk storage position, display
> position) for each column, I spent a little time messing around with a
> prototype implementation of column storage positions to see what kind
> of difference it would make.

I haven't understood Alvaro to suggest not keeping 3 numbers.

cheers

andrew


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, Phil Currier <pcurrier(at)gmail(dot)com>, "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 19:53:55
Message-ID: 20070221195355.GB25424@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Stephan Szabo escribió:
> On Wed, 21 Feb 2007, Martijn van Oosterhout wrote:
>
> > On Wed, Feb 21, 2007 at 12:06:30PM -0500, Phil Currier wrote:
> > > Well, for two reasons:
> > >
> > > 1) If you have a table with one very-frequently-accessed varchar()
> > > column and several not-frequently-accessed int columns, it might
> > > actually make sense to put the varchar column first. The system won't
> > > always be able to make the most intelligent decision about table
> > > layout.
> >
> > Umm, the point of the exercise is that if you know there are int
> > columns, then you can skip over them, whereas you can never skip over a
> > varchar column. So there isn't really any situation where it would be
> > better to put the varchar first.
>
> IIRC, in the first message in this thread, or another recent thread of
> this type, someone tried a reordering example with alternating
> smallints and varchar() and found that the leftmost varchar was
> actually slower to access after reordering, so I'm not sure that we can
> say there isn't a situation where it would affect things.

Offsets are cached in tuple accesses, but the caching is obviously
disabled for all attributes past any variable-length attribute. So if
you put a varlena attr in front, caching is completely disabled for all
attrs (but that first one). The automatic reordering algorithm must put
all fixed-len attrs at the front, so that their offets (and that of the
first variable length attr) can be cached.

Did I miss something in what you were trying to say? I assume you must
already know this.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Phil Currier <pcurrier(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 19:57:29
Message-ID: 20070221195729.GC25424@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan escribió:
> Simon Riggs wrote:
> >
> >I agree with comments here about the multiple orderings being a horrible
> >source of bugs, as well as lots of coding even to make it happen at all
> >http://archives.postgresql.org/pgsql-hackers/2006-12/msg00859.php
>
> I thought we were going with this later proposal of Tom's (on which he's
> convinced me):
> http://archives.postgresql.org/pgsql-hackers/2006-12/msg00983.php - if
> not I'm totally confused (situation normal). The current thread started
> with this sentence:
>
> >Inspired by this thread [1], and in particular by the idea of storing
> >three numbers (permanent ID, on-disk storage position, display
> >position) for each column, I spent a little time messing around with a
> >prototype implementation of column storage positions to see what kind
> >of difference it would make.
>
> I haven't understood Alvaro to suggest not keeping 3 numbers.

Right, I'm not advocating not doing that -- I'm just saying that the
first step to that could be decoupling physical position with attr id
:-) Logical column ordering (the order in which SELECT * expands to)
seems to me to be a different feature.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
Cc: "Phil Currier" <pcurrier(at)gmail(dot)com>, "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Column storage positions
Date: 2007-02-21 20:50:32
Message-ID: 87hctfp753.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


"Florian G. Pflug" <fgp(at)phlo(dot)org> writes:

> Why would a pg_migrator style upgrade use pg_dump at all? I assumed it
> would rather copy the verbatim data from the old to the new catalog,
> only changing it if the layout of the tables in pg_catalog actually changed.

The way pg_migrator works is does a pg_dump to move the schema to the new
postgres. Then it transfers the files and drops them into place where the new
schema expects to find them.

So yes, there would be a use case for specifying the physical column layout
when pg_migrator is doing the pg_dump/restore. But pg_migrator could probably
just update the physical column numbers itself. It's not like updating system
catalog tables directly is any more of an abstraction violation than swapping
files out from under the database...

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 20:55:31
Message-ID: 45DCB1C3.1090700@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera wrote:
>>
>> I haven't understood Alvaro to suggest not keeping 3 numbers.
>>
>
> Right, I'm not advocating not doing that -- I'm just saying that the
> first step to that could be decoupling physical position with attr id
> :-) Logical column ordering (the order in which SELECT * expands to)
> seems to me to be a different feature.
>
>

Except in the sense that divorcing the id from the storage order makes
it possible to do sanely. :-)

Incidentally, I'm sure there would be a full scale revolt if there was a
suggestion to alter the visible behaviour of SELECT *, COPY and other
commands that rely on the logical ordering (which is currently, and
unless we provide commands to alter it would stay as, the definition
order). That's the order pg_dump should use IMNSHO - it should never
have to worry about the physical order nor about explicitly setting the
logical order.

cheers

andrew


From: "Phil Currier" <pcurrier(at)gmail(dot)com>
To: "Gregory Stark" <stark(at)enterprisedb(dot)com>
Cc: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 21:17:19
Message-ID: c58979e50702211317s3df4ac7ct5cb2af2dbaed1008@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2/21/07, Gregory Stark <stark(at)enterprisedb(dot)com> wrote:
> So yes, there would be a use case for specifying the physical column layout
> when pg_migrator is doing the pg_dump/restore. But pg_migrator could probably
> just update the physical column numbers itself. It's not like updating system
> catalog tables directly is any more of an abstraction violation than swapping
> files out from under the database...

If people are ok with that answer, then I'll gladly stop suggesting
that ALTER TABLE be able to explicitly set storage positions. I was
just trying to avoid forcing a tool like pg_migrator to muck with the
system catalogs.

phil


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Phil Currier <pcurrier(at)gmail(dot)com>
Cc: Gregory Stark <stark(at)enterprisedb(dot)com>, "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 21:32:49
Message-ID: 20070221213249.GE25424@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Phil Currier escribió:
> On 2/21/07, Gregory Stark <stark(at)enterprisedb(dot)com> wrote:
> >So yes, there would be a use case for specifying the physical column layout
> >when pg_migrator is doing the pg_dump/restore. But pg_migrator could
> >probably
> >just update the physical column numbers itself. It's not like updating
> >system
> >catalog tables directly is any more of an abstraction violation than
> >swapping
> >files out from under the database...
>
> If people are ok with that answer, then I'll gladly stop suggesting
> that ALTER TABLE be able to explicitly set storage positions. I was
> just trying to avoid forcing a tool like pg_migrator to muck with the
> system catalogs.

I am ... that would be pg_migrator's goal anyway. And it's certainly
going to need knowledge on how to go from one version to the next.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, Phil Currier <pcurrier(at)gmail(dot)com>, "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 21:51:55
Message-ID: 20070221133728.G81529@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, 21 Feb 2007, Alvaro Herrera wrote:

> Stephan Szabo escribi:
> > On Wed, 21 Feb 2007, Martijn van Oosterhout wrote:
> >
> > > On Wed, Feb 21, 2007 at 12:06:30PM -0500, Phil Currier wrote:
> > > > Well, for two reasons:
> > > >
> > > > 1) If you have a table with one very-frequently-accessed varchar()
> > > > column and several not-frequently-accessed int columns, it might
> > > > actually make sense to put the varchar column first. The system won't
> > > > always be able to make the most intelligent decision about table
> > > > layout.
> > >
> > > Umm, the point of the exercise is that if you know there are int
> > > columns, then you can skip over them, whereas you can never skip over a
> > > varchar column. So there isn't really any situation where it would be
> > > better to put the varchar first.
> >
> > IIRC, in the first message in this thread, or another recent thread of
> > this type, someone tried a reordering example with alternating
> > smallints and varchar() and found that the leftmost varchar was
> > actually slower to access after reordering, so I'm not sure that we can
> > say there isn't a situation where it would affect things.
>
> Offsets are cached in tuple accesses, but the caching is obviously
> disabled for all attributes past any variable-length attribute. So if
> you put a varlena attr in front, caching is completely disabled for all
> attrs (but that first one). The automatic reordering algorithm must put
> all fixed-len attrs at the front, so that their offets (and that of the
> first variable length attr) can be cached.
>
> Did I miss something in what you were trying to say? I assume you must
> already know this.

I think so. What I was mentioning was that I was pretty sure that there
was a message with someone saying that they actually tried something that
did this and that they found left-most varchar access was slightly slower
after the reordering although general access was faster. I believe the
table case was alternating smallint and varchar columns, but I don't know
what was tested for the retrieval. If that turns out to be able to be
supported by other tests, then for some access patterns, the rearranged
version might be slower.


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, Phil Currier <pcurrier(at)gmail(dot)com>, "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 22:12:28
Message-ID: 45DCC3CC.4030206@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Stephan Szabo wrote:
> What I was mentioning was that I was pretty sure that there
> was a message with someone saying that they actually tried something that
> did this and that they found left-most varchar access was slightly slower
> after the reordering although general access was faster. I believe the
> table case was alternating smallint and varchar columns, but I don't know
> what was tested for the retrieval. If that turns out to be able to be
> supported by other tests, then for some access patterns, the rearranged
> version might be slower.
>
>

I would want to see this very carefully instrumented. Assuming we are
putting all fixed size objects at the front, which seems like the best
arrangement, then the position of every fixed field and the fixed
portion of the position of every varlena field can be precalculated (and
in the case of the leftmost varlena field that's it's complete
position). So the extra effort in getting to the leftmost varchar field
should be close to zero if this is done right, ISTM.

cheers

andrew


From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, Phil Currier <pcurrier(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 22:14:25
Message-ID: 45DCC441.5000709@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Stephan Szabo wrote:
> On Wed, 21 Feb 2007, Alvaro Herrera wrote:
>> Did I miss something in what you were trying to say? I assume you must
>> already know this.
>
> I think so. What I was mentioning was that I was pretty sure that there
> was a message with someone saying that they actually tried something that
> did this and that they found left-most varchar access was slightly slower
> after the reordering although general access was faster. I believe the
> table case was alternating smallint and varchar columns, but I don't know
> what was tested for the retrieval. If that turns out to be able to be
> supported by other tests, then for some access patterns, the rearranged
> version might be slower.

Here is the original quote:
----------------------------------------------------------------
The results were encouraging: on a table
with 20 columns of alternating smallint and varchar(10) datatypes,
selecting the max() of one of the rightmost int columns across 1
million rows ran around 3 times faster. The same query on the
leftmost varchar column (which should suffer the most from this
change) predictably got a little slower (about 10%);
----------------------------------------------------------------

What the OP doesn't mention is how the exact layouts looked before
and after the reordering - maybe a nullable field fixed-length field
got moved before the varchar column in question, which would disable
offset caching I guess.

Let's say the reodering algorithm is changed to only move non-nullable
fixed-width columns to the left - can anyone see an access pattern that
would run slower after the reodering? I certainly can't - because the set
of columns for which offset caching works after the reodering would
be a superset of the one for which it works before the reordering.

BTW, this is a good case for why the storage order should - directly or
indirectly - be tweakable. You can either optimize for space, and _then_
for speed - which is what the OP did I think - or first for speed, and then
for space. If the dba cannot choose the strategy, there will always be
workloads where the engine does it the wrong way around.

greetings, Florian Pflug


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
Cc: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, Phil Currier <pcurrier(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 22:37:05
Message-ID: 45DCC991.10501@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Florian G. Pflug wrote:
>
> BTW, this is a good case for why the storage order should - directly or
> indirectly - be tweakable. You can either optimize for space, and _then_
> for speed - which is what the OP did I think - or first for speed, and
> then for space. If the dba cannot choose the strategy, there will
> always be workloads where the engine does it the wrong way around.
>
>

Maybe a simple setting on ordering strategy would be OK. The chance of
mucking it up if you can directly set the physical order seems just too
great to me.

cheers

andrew


From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
Cc: "Stephan Szabo" <sszabo(at)megazone(dot)bigpanda(dot)com>, "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, "Phil Currier" <pcurrier(at)gmail(dot)com>, "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Column storage positions
Date: 2007-02-21 22:38:02
Message-ID: 87zm77nnlh.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Andrew Dunstan" <andrew(at)dunslane(dot)net> writes:

> I would want to see this very carefully instrumented. Assuming we are putting
> all fixed size objects at the front, which seems like the best arrangement,
> then the position of every fixed field and the fixed portion of the position of
> every varlena field can be precalculated (and in the case of the leftmost
> varlena field that's it's complete position).

I'm not sure what you mean by "the fixed portion of the position of every
varlena field". Fields are just stuck one after the other (plus alignment)
skipping nulls. So any field after a null or varlena field can't have its
position cached at all.

Sadly one effect of the 1-byte header varlenas is that the position of the
first varlena can't be cached any more. That's because its alignment depends
on whether you're storing a short varlena or a full 4-byte varlena.

Currently there's an exception for the first column of the table since that's
always at offset 0. We could add another exception and cache the first varlena
if it happens to land on an intaligned offset without any extra alignment. I'm
not sure if that pays for itself or not though. It still only helps 25% of the
time and only for the first varlena so it doesn't seem terribly important.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, Phil Currier <pcurrier(at)gmail(dot)com>, "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-21 23:31:35
Message-ID: 45DCD657.6040802@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Gregory Stark wrote:
> "Andrew Dunstan" <andrew(at)dunslane(dot)net> writes:
>
>
>> I would want to see this very carefully instrumented. Assuming we are putting
>> all fixed size objects at the front, which seems like the best arrangement,
>> then the position of every fixed field and the fixed portion of the position of
>> every varlena field can be precalculated (and in the case of the leftmost
>> varlena field that's it's complete position).
>>
>
> I'm not sure what you mean by "the fixed portion of the position of every
> varlena field". Fields are just stuck one after the other (plus alignment)
> skipping nulls. So any field after a null or varlena field can't have its
> position cached at all.
>

I'd forgotten about nulls :-( . Nevertheless, it's hard to think of a
case where the penalty for shifting fixed size fields to the front is
going to be very big. If we really wanted to optimise for speed for some
varlena case, we'd probably need to keep stats on usage patterns, but
that seems like massive overkill.

cheers

andrew


From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
Cc: "Stephan Szabo" <sszabo(at)megazone(dot)bigpanda(dot)com>, "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, "Phil Currier" <pcurrier(at)gmail(dot)com>, "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Column storage positions
Date: 2007-02-21 23:52:32
Message-ID: 871wkjnk5b.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Andrew Dunstan" <andrew(at)dunslane(dot)net> writes:

> Gregory Stark wrote:
>> "Andrew Dunstan" <andrew(at)dunslane(dot)net> writes:
>>
>>
>>> I would want to see this very carefully instrumented. Assuming we are putting
>>> all fixed size objects at the front, which seems like the best arrangement,
>>> then the position of every fixed field and the fixed portion of the position of
>>> every varlena field can be precalculated (and in the case of the leftmost
>>> varlena field that's it's complete position).
>>
>> I'm not sure what you mean by "the fixed portion of the position of every
>> varlena field". Fields are just stuck one after the other (plus alignment)
>> skipping nulls. So any field after a null or varlena field can't have its
>> position cached at all.
>
> I'd forgotten about nulls :-( . Nevertheless, it's hard to think of a case
> where the penalty for shifting fixed size fields to the front is going to be
> very big. If we really wanted to optimise for speed for some varlena case, we'd
> probably need to keep stats on usage patterns, but that seems like massive
> overkill.

Oh, certainly, especially since only one varlena could ever be cached and soon
even that one won't be unless it's the very first column in the table. So
really, not worth thinking about.

Well the statistics we have do include the percentage of nulls in each column,
so we can sort columns by "fixed width not null" first, then "fixed width
nullable" by decreasing probability of being null, then varlenas.

But there's a tradeoff here. The more we try to optimize for cacheable offsets
the more difficult it will be to pack away the alignments.

Consider something like:

int not null
boolean not null
int null
text null

If we want we can pack this as int,int,boolean,text and (as long as the text
gets a 1-byte header) have them packed with no alignment.

But then the boolean can't use the cache whenever the int column is null. (the
offset will still be cached but it won't be used unless the int column is
non-null).

Alternatively we can pack this as int,boolean,int,text in which case the
boolean will *always* use the cache but it will be preceded by three wasted
padding bytes.

I tend to think the padding is more important than the caching because in
large systems the i/o speed dominates. But that doesn't mean the cpu cost is
negligible either. Especially on very wide tables.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com


From: elein <elein(at)varlena(dot)com>
To: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Phil Currier <pcurrier(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-22 02:06:50
Message-ID: 20070222020650.GB1867@varlena.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Feb 21, 2007 at 08:33:10PM +0100, Florian G. Pflug wrote:
> Simon Riggs wrote:
> >On Wed, 2007-02-21 at 09:25 -0500, Phil Currier wrote:
> >>On 2/21/07, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
> >>>I'd expect the system being able to reoder the columns to the most
> >>>efficient order possible (performance-wise and padding-saving-wise),
> >>>automatically. When you create a table, sort the columns to the most
> >>>efficient order; ALTER TABLE ADD COLUMN just puts the new columns at the
> >>>end of the tuple; and anything that requires a rewrite of the table
> >>>(ALTER TABLE ... ALTER TYPE for example; would be cool to have CLUSTER
> >>>do it as well; and do it on TRUNCATE also) again recomputes the most
> >>>efficient order.
> >>That's exactly what I'm proposing. On table creation, the system
> >>chooses an efficient column order for you.
> >
> >That's fairly straightforward and beneficial. I much prefer Alvaro's
> >approach rather than the storage position details originally described.
> >Moreover, you'd need to significantly re-write lots of ALTER TABLE and I
> >really don't think you want to go there.
> >
> >There is a problem: If people do a CREATE TABLE and then issue SELECT *
> >they will find the columns in a different order. That could actually
> >break some programs, so it isn't acceptable in all cases. e.g. COPY
> >without a column-list assumes that the incoming data should be assigned
> >to the table columns in the same order as the incoming data file.
>
> But the display order (and hence the COPY order) of columns would still
> be determinted by attnum, not by some attstoragepos, no?
> The column reordering would only apply to the physical storage of
> columns, not to how it's presented to the user I'd think.
>
> The original idea was to add a third column, attdisplaypos, and let the
> user choose the display ordering independent from the unique id
> (attnum), which in turn is independent from the storage position.
>
> For simplicity, the OP said he omitted the display-position part here,
> because it's really orthogonal to being able to modify the storage position.
>

IMHO I think display order is very important to users. First, don't
break the select *, no matter how bad it is to code that. Next, don't
break copy or pg_dump/restore. We've fielded a lot of questions on
the ordering of columns for display and simplicity reasons.

The storage order is orthogonal to the display order. display order can be handled
in attnum and the new storage order can be the new column.

--elein


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Phil Currier <pcurrier(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-22 02:28:53
Message-ID: 45DCFFE5.9010406@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

elein wrote:
>
> The storage order is orthogonal to the display order. display order can be handled
> in attnum and the new storage order can be the new column.
>
>
>

If you review the earlier discussion you will see that it is proposed
(by Tom) to have 3 numbers (i.e. 2 new cols): an immutable id and
mutable storage/physical order and display/logical order.

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-22 06:37:50
Message-ID: 6843.1172126270@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> Alvaro Herrera wrote:
>> Right, I'm not advocating not doing that -- I'm just saying that the
>> first step to that could be decoupling physical position with attr id
>> :-) Logical column ordering (the order in which SELECT * expands to)
>> seems to me to be a different feature.

> Except in the sense that divorcing the id from the storage order makes
> it possible to do sanely. :-)

They are different features, but they are going to hit all the same
code, because the hardest part of this remains making sure that every
piece of the code is using the right kind of column number. The
suggestion I posted awhile ago amounts to saying that we might be able
to solve that by default, by making sure that only one definition of
"column number" is relevant to the majority of the backend and we can
figure out exactly where the other definitions need to apply. But
that's handwaving until someone actually does it :-(

In any case I think it's foolish not to tackle both issues at once.
We know we'd like to have both features and we know that all the same
bits of code need to be looked at to implement either.

regards, tom lane


From: "Simon Riggs" <simon(at)2ndquadrant(dot)com>
To: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>
Cc: "Andrew Dunstan" <andrew(at)dunslane(dot)net>, "Phil Currier" <pcurrier(at)gmail(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Column storage positions
Date: 2007-02-22 11:03:28
Message-ID: 1172142209.3874.100.camel@silverbirch.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, 2007-02-21 at 16:57 -0300, Alvaro Herrera wrote:
> Andrew Dunstan escribió:
> > Simon Riggs wrote:
> > >
> > >I agree with comments here about the multiple orderings being a horrible
> > >source of bugs, as well as lots of coding even to make it happen at all
> > >http://archives.postgresql.org/pgsql-hackers/2006-12/msg00859.php
> >
> > I thought we were going with this later proposal of Tom's (on which he's
> > convinced me):
> > http://archives.postgresql.org/pgsql-hackers/2006-12/msg00983.php - if
> > not I'm totally confused (situation normal). The current thread started
> > with this sentence:
> >
> > >Inspired by this thread [1], and in particular by the idea of storing
> > >three numbers (permanent ID, on-disk storage position, display
> > >position) for each column, I spent a little time messing around with a
> > >prototype implementation of column storage positions to see what kind
> > >of difference it would make.
> >
> > I haven't understood Alvaro to suggest not keeping 3 numbers.
>
> Right, I'm not advocating not doing that -- I'm just saying that the
> first step to that could be decoupling physical position with attr id
> :-) Logical column ordering (the order in which SELECT * expands to)
> seems to me to be a different feature.

Not disagreed. :-)

Something very, very simple seems most likely to be an effective
additional feature for 8.3. We can implement the 2/3 position version
for 8.4

--
Simon Riggs
EnterpriseDB http://www.enterprisedb.com


From: "Phil Currier" <pcurrier(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Andrew Dunstan" <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-22 14:06:48
Message-ID: c58979e50702220606g467c10adva50845b6086825b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2/22/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> > Alvaro Herrera wrote:
> >> Right, I'm not advocating not doing that -- I'm just saying that the
> >> first step to that could be decoupling physical position with attr id
> >> :-) Logical column ordering (the order in which SELECT * expands to)
> >> seems to me to be a different feature.
>
> > Except in the sense that divorcing the id from the storage order makes
> > it possible to do sanely. :-)
>
> They are different features, but they are going to hit all the same
> code, because the hardest part of this remains making sure that every
> piece of the code is using the right kind of column number. The
> suggestion I posted awhile ago amounts to saying that we might be able
> to solve that by default, by making sure that only one definition of
> "column number" is relevant to the majority of the backend and we can
> figure out exactly where the other definitions need to apply. But
> that's handwaving until someone actually does it :-(

I don't really think it's just handwaving at this point because I've
done a lot of it :). I'm not saying the work is done, or that a lot
more testing isn't required, but at the moment I have a working system
that seems to do what it needs to do to separate storage position from
permanent ID/display position. And the changes to accomplish this
were quite localized - namely the tuple access routines in
heaptuple.c, and the small handful of places that need to construct
tuple descriptors. That's pretty much it - the rest of the codebase
is remains untouched.

> In any case I think it's foolish not to tackle both issues at once.
> We know we'd like to have both features and we know that all the same
> bits of code need to be looked at to implement either.

I guess I disagree with that sentiment. I don't think it's necessary
to bundle these two features together, even if some analysis will be
duplicated between them, since they are completely distinct in a
functional sense and will touch different places in the code.
Smaller, more incremental changes make more sense to me.

But if both-features-at-once is what the community wants, that's fine,
no worries. I'll just pull my own personal hat out of the ring until
someone comes along who's interested in implementing them both at the
same time.

phil


From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Cc: "Phil Currier" <pcurrier(at)gmail(dot)com>
Subject: Re: Column storage positions
Date: 2007-02-22 16:20:18
Message-ID: 200702221120.18961.xzilla@users.sourceforge.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thursday 22 February 2007 09:06, Phil Currier wrote:
> On 2/22/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> > > Alvaro Herrera wrote:
> > >> Right, I'm not advocating not doing that -- I'm just saying that the
> > >> first step to that could be decoupling physical position with attr id
> > >>
> > >> :-) Logical column ordering (the order in which SELECT * expands to)
> > >>
> > >> seems to me to be a different feature.
> > >
> > > Except in the sense that divorcing the id from the storage order makes
> > > it possible to do sanely. :-)
> >
> > They are different features, but they are going to hit all the same
> > code, because the hardest part of this remains making sure that every
> > piece of the code is using the right kind of column number. The
> > suggestion I posted awhile ago amounts to saying that we might be able
> > to solve that by default, by making sure that only one definition of
> > "column number" is relevant to the majority of the backend and we can
> > figure out exactly where the other definitions need to apply. But
> > that's handwaving until someone actually does it :-(
>
> I don't really think it's just handwaving at this point because I've
> done a lot of it :). I'm not saying the work is done, or that a lot
> more testing isn't required, but at the moment I have a working system
> that seems to do what it needs to do to separate storage position from
> permanent ID/display position. And the changes to accomplish this
> were quite localized - namely the tuple access routines in
> heaptuple.c, and the small handful of places that need to construct
> tuple descriptors. That's pretty much it - the rest of the codebase
> is remains untouched.
>
> > In any case I think it's foolish not to tackle both issues at once.
> > We know we'd like to have both features and we know that all the same
> > bits of code need to be looked at to implement either.
>
> I guess I disagree with that sentiment. I don't think it's necessary
> to bundle these two features together, even if some analysis will be
> duplicated between them, since they are completely distinct in a
> functional sense and will touch different places in the code.
> Smaller, more incremental changes make more sense to me.
>

Can you post a patch of what you have now to -patches?

> But if both-features-at-once is what the community wants, that's fine,
> no worries. I'll just pull my own personal hat out of the ring until
> someone comes along who's interested in implementing them both at the
> same time.
>

Are you that opposed to working on the display portions as well? You'll be a
hero to thousands of mysql users if you do it.

--
Robert Treat
Build A Brighter LAMP :: Linux Apache {middleware} PostgreSQL


From: "Zeugswetter Andreas ADI SD" <ZeugswetterA(at)spardat(dot)at>
To: "Phil Currier" <pcurrier(at)gmail(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Andrew Dunstan" <andrew(at)dunslane(dot)net>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Column storage positions
Date: 2007-02-22 16:30:24
Message-ID: E1539E0ED7043848906A8FF995BDA57901CAF70E@m0143.s-mxs.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


> > In any case I think it's foolish not to tackle both issues at once.
> > We know we'd like to have both features and we know that
> all the same
> > bits of code need to be looked at to implement either.
>
> I guess I disagree with that sentiment. I don't think it's
> necessary to bundle these two features together, even if some
> analysis will be duplicated between them, since they are
> completely distinct in a functional sense and will touch
> different places in the code.

I fully agree with Phil here.

And I also see a lot of unhappiness from users of system tables
when column numbers all over the system tables would not be logical
column
positions any more.

Andreas


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Zeugswetter Andreas ADI SD <ZeugswetterA(at)spardat(dot)at>
Cc: Phil Currier <pcurrier(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-22 17:16:13
Message-ID: 45DDCFDD.5090408@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Zeugswetter Andreas ADI SD wrote:
> And I also see a lot of unhappiness from users of system tables
> when column numbers all over the system tables would not be logical
> column
> positions any more.
>
>

Are you arguing against the feature? Or against the suggested design?

I should have thought (without much looking) one possible way to
implement it would be to put Oids on pg_attribute for the permanent id,
and keep attnum for the (now mutable) logical order, adding a further
column for the physical order.

cheers

andrew


From: "Zeugswetter Andreas ADI SD" <ZeugswetterA(at)spardat(dot)at>
To: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
Cc: "Phil Currier" <pcurrier(at)gmail(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Column storage positions
Date: 2007-02-22 17:25:10
Message-ID: E1539E0ED7043848906A8FF995BDA57901CAF723@m0143.s-mxs.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


> > And I also see a lot of unhappiness from users of system tables when

> > column numbers all over the system tables would not be logical
column
> > positions any more.
>
> Are you arguing against the feature? Or against the suggested design?

Against the design.

> I should have thought (without much looking) one possible way
> to implement it would be to put Oids on pg_attribute for the
> permanent id, and keep attnum for the (now mutable) logical
> order, adding a further column for the physical order.

Yes, that was the idea (not oid but some number), and I am arguing
against it. Imho people are used to see the logical position in e.g.
pg_index

I know it is a lot of work to update all those dependencies in the
system tables to reorder logical position, but that is the path I think
should be taken. And the first step in that direction is Phil's patch.

Andreas


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Zeugswetter Andreas ADI SD <ZeugswetterA(at)spardat(dot)at>
Cc: Phil Currier <pcurrier(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-22 17:33:14
Message-ID: 45DDD3DA.5040305@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Zeugswetter Andreas ADI SD wrote:
>
> Yes, that was the idea (not oid but some number), and I am arguing
> against it. Imho people are used to see the logical position in e.g.
> pg_index
>
>
>

Which people are you talking about? In my commercial PG work I hardly
ever look at a system table at all, and users shouldn't have to IMNSHO.
If you mean tools developers, then accomodating to catalog changes is
par for the course, I should think.

cheers

andrew


From: "Zeugswetter Andreas ADI SD" <ZeugswetterA(at)spardat(dot)at>
To: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
Cc: "Phil Currier" <pcurrier(at)gmail(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Column storage positions
Date: 2007-02-22 18:02:52
Message-ID: E1539E0ED7043848906A8FF995BDA57901CAF728@m0143.s-mxs.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


> > Yes, that was the idea (not oid but some number), and I am arguing
> > against it. Imho people are used to see the logical position in e.g.
> > pg_index
> >
>
> Which people are you talking about? In my commercial PG work
> I hardly ever look at a system table at all, and users
> shouldn't have to IMNSHO.

You are probably right. I tend to resort to commandline tools, schema
dumps and system tables, probably not many other "people" do that. I
often don't get to use my perferred toolset because it is not installed.

> If you mean tools developers, then accomodating to catalog
> changes is par for the course, I should think.

The question is, whether the distributed work needed to get all the
tools and interfaces (like jdbc, odbc, pgadmin) to work again isn't more
work, than doing it in the backend would be.

Since we want plan invalidation anyway, I am not sure the rest is so
much.

Andreas


From: Kris Jurka <books(at)ejurka(dot)com>
To: Zeugswetter Andreas ADI SD <ZeugswetterA(at)spardat(dot)at>
Cc: Phil Currier <pcurrier(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-22 18:13:07
Message-ID: Pine.BSO.4.64.0702221310460.11771@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, 22 Feb 2007, Zeugswetter Andreas ADI SD wrote:

> And I also see a lot of unhappiness from users of system tables when
> column numbers all over the system tables would not be logical column
> positions any more.
>

Right now the fact that attnum presents the logical order but not the
logical position is a problem for the JDBC driver. In the presence of
dropped columns there is no easy way to get from a pg_attribute entry to
logical position. I would hope that a new logical position column would
reflect the actual position and solve this problem.

Kris Jurka


From: "Zeugswetter Andreas ADI SD" <ZeugswetterA(at)spardat(dot)at>
To: "Kris Jurka" <books(at)ejurka(dot)com>
Cc: "Phil Currier" <pcurrier(at)gmail(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Andrew Dunstan" <andrew(at)dunslane(dot)net>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Column storage positions
Date: 2007-02-22 18:23:39
Message-ID: E1539E0ED7043848906A8FF995BDA57901CAF72A@m0143.s-mxs.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


> > And I also see a lot of unhappiness from users of system tables when

> > column numbers all over the system tables would not be logical
column
> > positions any more.
>
> Right now the fact that attnum presents the logical order but
> not the logical position is a problem for the JDBC driver.
> In the presence of dropped columns there is no easy way to
> get from a pg_attribute entry to logical position. I would
> hope that a new logical position column would reflect the
> actual position and solve this problem.

I agree, I haven't thought of drop column :-( Drop column should have
relabeled attnum.
Since it was not done then, my comments are probably moot.

Andreas


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Zeugswetter Andreas ADI SD <ZeugswetterA(at)spardat(dot)at>
Cc: Kris Jurka <books(at)ejurka(dot)com>, Phil Currier <pcurrier(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-22 18:47:23
Message-ID: 20070222184723.GO4276@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Zeugswetter Andreas ADI SD escribió:
>
> > > And I also see a lot of unhappiness from users of system tables
> > > when column numbers all over the system tables would not be
> > > logical column positions any more.
> >
> > Right now the fact that attnum presents the logical order but
> > not the logical position is a problem for the JDBC driver.
> > In the presence of dropped columns there is no easy way to
> > get from a pg_attribute entry to logical position. I would
> > hope that a new logical position column would reflect the
> > actual position and solve this problem.
>
> I agree, I haven't thought of drop column :-( Drop column should have
> relabeled attnum.
> Since it was not done then, my comments are probably moot.

We can correct this problem now.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: Kris Jurka <books(at)ejurka(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Zeugswetter Andreas ADI SD <ZeugswetterA(at)spardat(dot)at>, Phil Currier <pcurrier(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-22 18:55:47
Message-ID: Pine.BSO.4.64.0702221354470.14645@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, 22 Feb 2007, Alvaro Herrera wrote:

> Zeugswetter Andreas ADI SD escribió:
>>
>> I agree, I haven't thought of drop column :-( Drop column should have
>> relabeled attnum. Since it was not done then, my comments are probably
>> moot.
>
> We can correct this problem now.
>

How? If attnum is serving as both physical position and logical order,
how can you make it be logical position without breaking physical
position?

Kris Jurka


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: Zeugswetter Andreas ADI SD <ZeugswetterA(at)spardat(dot)at>, Phil Currier <pcurrier(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-02-22 19:10:01
Message-ID: 20070222191001.GP4276@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Kris Jurka escribió:
>
>
> On Thu, 22 Feb 2007, Alvaro Herrera wrote:
>
> >Zeugswetter Andreas ADI SD escribió:
> >>
> >>I agree, I haven't thought of drop column :-( Drop column should have
> >>relabeled attnum. Since it was not done then, my comments are probably
> >>moot.
> >
> >We can correct this problem now.
>
> How? If attnum is serving as both physical position and logical order,
> how can you make it be logical position without breaking physical
> position?

By patching the code, of course, so that it doesn't serves as both
things, which is what is being discussed.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: "Zeugswetter Andreas ADI SD" <ZeugswetterA(at)spardat(dot)at>
To: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>
Cc: "Kris Jurka" <books(at)ejurka(dot)com>, "Phil Currier" <pcurrier(at)gmail(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Andrew Dunstan" <andrew(at)dunslane(dot)net>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Column storage positions
Date: 2007-02-22 19:15:13
Message-ID: E1539E0ED7043848906A8FF995BDA57901CAF737@m0143.s-mxs.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


> > I agree, I haven't thought of drop column :-( Drop column should
have
> > relabeled attnum.
> > Since it was not done then, my comments are probably moot.
>
> We can correct this problem now.

Do you mean fix it with the 3rd column in pg_attribute and use that,
or fix attnum ? :-)

Imho it is a pain to need 2 numbers and a mapping in drivers.

Andreas


From: "Zeugswetter Andreas ADI SD" <ZeugswetterA(at)spardat(dot)at>
To: "Kris Jurka" <books(at)ejurka(dot)com>, "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>
Cc: "Phil Currier" <pcurrier(at)gmail(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Andrew Dunstan" <andrew(at)dunslane(dot)net>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Column storage positions
Date: 2007-02-22 19:25:22
Message-ID: E1539E0ED7043848906A8FF995BDA57901CAF738@m0143.s-mxs.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


> >> I agree, I haven't thought of drop column :-( Drop column should
have
> >> relabeled attnum. Since it was not done then, my comments are
> >> probably moot.
> >
> > We can correct this problem now.
>
> How? If attnum is serving as both physical position and
> logical order, how can you make it be logical position
> without breaking physical position?

If you ask me, attnum would be the logical position and would be used
in all other system tables. attphypos would only be used in
pg_attribute.
It would be quite some work to rearrange attnum in all system tables for
"drop column" and "add column before", but it would be nice for jdbc.

But it seems others want this: attnum beeing an arbitrary number,
that is used in all system tables and 2 extra columns in pg_attribute,
one for logical position and one for physical position.
If you want a corresponding colname to a pg_index attnum you need a map.

Andreas


From: "Guillaume Smet" <guillaume(dot)smet(at)gmail(dot)com>
To: "Phil Currier" <pcurrier(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-04-01 15:13:39
Message-ID: 1d4e0c10704010813g4ed1a505p577db72d30369e77@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2/20/07, Phil Currier <pcurrier(at)gmail(dot)com> wrote:
> Inspired by this thread [1], and in particular by the idea of storing
> three numbers (permanent ID, on-disk storage position, display
> position) for each column, I spent a little time messing around with a
> prototype implementation of column storage positions to see what kind
> of difference it would make.

Phil, did you make any progress with your patch? Your results seemed
very encouraging and your implementation interesting.
IIRC, the problem was that you weren't interested in working on the
"visual/mysqlish" column ordering. As the plan was to decouple column
ordering in three different orderings, I don't think it's really a
problem if your implementation doesn't support one of them (at least
if it doesn't prevent us from having the visual one someday).

Is there any chance you keep us posted with your progress and post a
preliminary patch exposing your design choices? This could allow other
people to see if there are interesting results with their particular
database and workload.

It's too late for 8.3 but it could be a nice thing to have in 8.4.

Thanks in advance.

Regards.

--
Guillaume


From: "Phil Currier" <pcurrier(at)gmail(dot)com>
To: "Guillaume Smet" <guillaume(dot)smet(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-04-02 00:44:52
Message-ID: c58979e50704011744l14c953b0v744f94fe36e74981@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 4/1/07, Guillaume Smet <guillaume(dot)smet(at)gmail(dot)com> wrote:
> Phil, did you make any progress with your patch? Your results seemed
> very encouraging and your implementation interesting.
> IIRC, the problem was that you weren't interested in working on the
> "visual/mysqlish" column ordering. As the plan was to decouple column
> ordering in three different orderings, I don't think it's really a
> problem if your implementation doesn't support one of them (at least
> if it doesn't prevent us from having the visual one someday).

I haven't done much with it since February, largely because my
available free time evaporated. But I do intend to get back to it
when I have a chance. But you're right, the storage position stuff
I've worked on is completely independent from display positions, and
certainly wouldn't prevent that being added separately.

> Is there any chance you keep us posted with your progress and post a
> preliminary patch exposing your design choices? This could allow other
> people to see if there are interesting results with their particular
> database and workload.

Yeah, I'll try to clean things up and post a patch eventually. And if
anyone feels like working on the display position piece, let me know;
perhaps we could pool our efforts for 8.4.

phil


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Phil Currier <pcurrier(at)gmail(dot)com>
Cc: Guillaume Smet <guillaume(dot)smet(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2007-04-02 01:47:06
Message-ID: 4610609A.4090007@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Phil Currier wrote:
> I haven't done much with it since February, largely because my
> available free time evaporated. But I do intend to get back to it
> when I have a chance. But you're right, the storage position stuff
> I've worked on is completely independent from display positions, and
> certainly wouldn't prevent that being added separately.

I agree with this comment from Tom last time it was discussed:

> In any case I think it's foolish not to tackle both issues at once.
> We know we'd like to have both features and we know that all the same
> bits of code need to be looked at to implement either.

Just tackling the side of the problem that interests you is probably not
the ideal way to go.

cheers

andrew


From: "Guillaume Smet" <guillaume(dot)smet(at)gmail(dot)com>
To: "Phil Currier" <pcurrier(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Column storage positions
Date: 2008-04-30 13:37:26
Message-ID: 1d4e0c10804300637w39a2f18bj96661d6e545b5cd2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Apr 2, 2007 at 2:44 AM, Phil Currier <pcurrier(at)gmail(dot)com> wrote:
> On 4/1/07, Guillaume Smet <guillaume(dot)smet(at)gmail(dot)com> wrote:
>
> > Phil, did you make any progress with your patch? Your results seemed
> > very encouraging and your implementation interesting.
> > IIRC, the problem was that you weren't interested in working on the
> > "visual/mysqlish" column ordering. As the plan was to decouple column
> > ordering in three different orderings, I don't think it's really a
> > problem if your implementation doesn't support one of them (at least
> > if it doesn't prevent us from having the visual one someday).
> >
>
> I haven't done much with it since February, largely because my
> available free time evaporated. But I do intend to get back to it
> when I have a chance. But you're right, the storage position stuff
> I've worked on is completely independent from display positions, and
> certainly wouldn't prevent that being added separately.
>
>
>
> > Is there any chance you keep us posted with your progress and post a
> > preliminary patch exposing your design choices? This could allow other
> > people to see if there are interesting results with their particular
> > database and workload.
> >
>
> Yeah, I'll try to clean things up and post a patch eventually. And if
> anyone feels like working on the display position piece, let me know;
> perhaps we could pool our efforts for 8.4.

Hi Phil,

Did you make any progress on this cleanup? It seems like a good timing
to revive this project if we want it for 8.4.

Thanks for your feedback.

--
Guillaume