Tom Dunstan <[EMAIL PROTECTED]> writes: > Andrew and I got together and worked out a more detailed idea of how we > want to add enums to the postgresql core. This follows on from his > original enumkit prototype last year [1]. Here's a more formal proposal > / design with what we came up with. Comments / criticism hereby solicited. > ... > On disk, enums will occupy 4 bytes: the high 22 bits will be an enum > identifier, with the bottom 10 bits being the enum value. This allows > 1024 values for a given enum, and 2^22 different enum types, both of > which should be heaps. The exact distribution of bits doesn't matter all > that much, we just picked some that we were comfortable with.
I think this is excessive concern for bit-shaving. Make the on-disk representation be 8 bytes instead of 4, then you can store the OID directly and have no need for the separate identifier concept. This in turn eliminates one index, one syscache, and one set of lookup/cache routines. And you can have as many values of an enum as you darn please. > The i/o functions will both cache enum info in the same way that the > domain and composite type i/o functions do, by attaching the data to the > fcinfo->flinfo->fn_extra pointer. The input function will look up the > enum data in the syscache using the type oid that it will be passed, and > cache it in a hashtable or binary tree for easy repeated lookup. If you didn't notice already: typcache is the place to put any type-related caching you need to add. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org