Skip site navigation (1) Skip section navigation (2)

Re: Enums patch v2

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgresql(dot)org, Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
Cc: Tom Dunstan <pgsql(at)tomd(dot)cc>, pgsql-patches(at)postgresql(dot)org
Subject: Re: Enums patch v2
Date: 2006-12-19 08:23:23
Message-ID: 17858.1166516603@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Heikki Linnakangas <heikki(at)enterprisedb(dot)com> writes:
> Ignoring my general dislike of enums, I have a few issues with the patch 
> as it is:

> 1. What's the point of having comparison operators for enums? For most 
> use cases, there's no natural ordering of enum values.

If you would like to be able to index enum columns, or even GROUP BY one,
you need those; whether the ordering is arbitrary or not is irrelevant.

> 2. The comparison routine compares oids, right? If the oids wrap around 
> when the enum values are created, the ordering isn't what the user expects.

This is a fair point --- it'd be better if the ordering were not
dependent on chance OID assignments.  Not sure what we are willing
to pay to have that though.

> 3. 4 bytes per value is wasteful if you're storing simple status codes 
> etc.

I've forgotten exactly which design Tom is proposing to implement here,
but at least one of the contenders involved storing an OID that would be
unique across all enum types.  1 byte is certainly not enough for that
and even 2 bytes would be pretty marginal.  I'm unconvinced by arguments
about 2 bytes being so much better than 4 anyway --- in the majority of
real table layouts, the hoped-for savings would disappear into alignment
padding.

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Dave PageDate: 2006-12-19 08:24:39
Subject: Re: pg_restore fails with a custom backup file
Previous:From: Heikki LinnakangasDate: 2006-12-19 08:09:47
Subject: Re: Enums patch v2

pgsql-patches by date

Next:From: Simon RiggsDate: 2006-12-19 08:47:04
Subject: explain_analyze_timer
Previous:From: Heikki LinnakangasDate: 2006-12-19 08:09:47
Subject: Re: Enums patch v2

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group