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

Re: Question on simulating Enum Data type

From: "Morgan Kita" <mkita(at)verseon(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Question on simulating Enum Data type
Date: 2005-03-18 22:42:47
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Hmm still I wonder, won't the varchar/char compares be much slower than using a seperate map table, grabbing the int value, and then only doing int compares? Maybe somebody can enlighten me on the relative speed of queries involving string compares vs queries on int compares.

-----Original Message-----
From: pgsql-novice-owner(at)postgresql(dot)org
[mailto:pgsql-novice-owner(at)postgresql(dot)org]On Behalf Of Tom Lane
Sent: Thursday, March 17, 2005 6:58 PM
To: Morgan Kita
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: [NOVICE] Question on simulating Enum Data type 

"Morgan Kita" <mkita(at)verseon(dot)com> writes:
> However, I am a little concerned about performance in that case. If I
> use domain constraints and keep the choices as strings then a string
> comparison will be done whenver I query on this field right?

Hm?  A domain constraint would cost cycles when storing into the table,
but not when querying it.  Joining to another table, on the other hand,
will cost you during queries.

If the strings are long, so that the amount of extra space involved adds
up to a lot, it'd probably make sense to go with integer codes.  But if
they're just a word or so then I'd lean to keeping it simple.


pgsql-novice by date

Next:From: Morgan KitaDate: 2005-03-18 23:10:36
Subject: Best way to input data
Previous:From: Tom LaneDate: 2005-03-18 21:57:51
Subject: Re: Query optimization

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