Question on simulating Enum Data type
От
Morgan Kita
Тема
Question on simulating Enum Data type
Дата
Msg-id
08B420FF5BF7BC42A064212C2EB768801C108D@neutron.verseon.com
Список
Дерево обсуждения
Question on simulating Enum Data type "Morgan Kita" <mkita@verseon.com>
Re: Question on simulating Enum Data type Tom Lane <tgl@sss.pgh.pa.us>
Re: Question on simulating Enum Data type Michael Glaesemann <grzm@myrealbox.com>
Ok this is noobish, but I am new to both databases and especially PostgreSQL. I am planning out how I am going to setup my database schema, and I have quite a few fields in the different tables where I would like to set up an enum type similar to C and C++ style enum types. Essentially these fields will have like 5-15 choices, and the tables themselves might have on the order of 10 million rows. Now I know I can pretty easily simulate this with domain constraints. 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? I know an index will speed this up quite a bit but even so I may have to do 10s of thousands of string compares if there are only 5 choices right? Ideally wouldn't it be better to store an integer field in the tables, and then keep a seperate small map table? Then the application could use the map table to look up the key and then do a query on the large table using only integer compares? Am I just being silly or am I not understanding something here? Maybe there is another way to do this? Thanks, Morgan
В списке pgsql-novice по дате отправления