Question on simulating Enum Data type
От | Morgan Kita |
---|---|
Тема | Question on simulating Enum Data type |
Дата | |
Msg-id | 08B420FF5BF7BC42A064212C2EB768801C108D@neutron.verseon.com обсуждение исходный текст |
Ответы |
Re: Question on simulating Enum Data type
Re: Question on simulating Enum Data type |
Список | pgsql-novice |
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 whereI would like to set up an enum type similar to C and C++ style enum types. Essentially these fields will have like 5-15choices, and the tables themselves might have on the order of 10 million rows. Now I know I can pretty easily simulatethis with domain constraints. However, I am a little concerned about performance in that case. If I use domain constraints and keep the choices as stringsthen a string comparison will be done whenver I query on this field right? I know an index will speed this up quitea 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 theapplication 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 по дате отправления: