 |
|
 |
|
Next: Subquery Question
|
| Author |
Message |
External

Since: Feb 18, 2005 Posts: 1
|
(Msg. 1) Posted: Fri Feb 18, 2005 2:16 am
Post subject: enum vs tinyint Archived from groups: mailing>database>mysql (more info?)
|
|
|
For instance, there is one column has values 'New', 'Maintenance',
'Renovation', 'Not Specified', and which options below is better in
term of performance?
option 1.
set the column to tinyint unsigned not null, and store the value
1,2,3,4. The values 1,2,3,4 represent the values 'New', 'Maintenance',
'Renovation', 'Not Specified' respectively in another lookup table.
When i want to select a list of data, the sql is
"SELECT col1, colvalue FROM tbl1 LEFT JOIN tbl2 ON (tbl1.col1 =
tbl2.col2) LIMIT 0, 100".
tbl1 is main data table, tbl2 is lookup table, and both col1 and col2
column type is tinyint unsigned not null. colvalue column is 'New',
'Maintenance', 'Renovation', 'Not Specified'.
option 2
set the column to enum('n', 'm', 'r', 's'). The values 'n', 'm', 'r',
's' represent the values 'New', 'Maintenance', 'Renovation', 'Not
Specified' respectively in another lookup table. When i want to select
a list of data, the sql is
"SELECT col1, colvalue FROM tbl1 LEFT JOIN tbl2 ON (tbl1.col1 =
tbl2.col2) LIMIT 0, 100".
tbl1 is main data table, tbl2 is lookup table, and both col1 and col2
column type isenum('n', 'm', 'r', 's'). colvalue column is 'New',
'Maintenance', 'Renovation', 'Not Specified'.
Assume both the col1 and col2 are indexed
Thank you >> Stay informed about: enum vs tinyint |
|
| Back to top |
|
 |  |
External

Since: Jan 05, 2005 Posts: 3
|
(Msg. 2) Posted: Fri Feb 18, 2005 6:40 am
Post subject: Re: enum vs tinyint [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On 18 Feb 2005 01:16:24 -0800, in mailing.database.mysql
" " wrote:
>| For instance, there is one column has values 'New', 'Maintenance',
>| 'Renovation', 'Not Specified', and which options below is better in
>| term of performance?
>|
>| option 1.
>| set the column to tinyint unsigned not null, and store the value
>| 1,2,3,4. The values 1,2,3,4 represent the values 'New', 'Maintenance',
>| 'Renovation', 'Not Specified' respectively in another lookup table.
>| When i want to select a list of data, the sql is
>| "SELECT col1, colvalue FROM tbl1 LEFT JOIN tbl2 ON (tbl1.col1 =
>| tbl2.col2) LIMIT 0, 100".
>| tbl1 is main data table, tbl2 is lookup table, and both col1 and col2
>| column type is tinyint unsigned not null. colvalue column is 'New',
>| 'Maintenance', 'Renovation', 'Not Specified'.
>|
>| option 2
>| set the column to enum('n', 'm', 'r', 's'). The values 'n', 'm', 'r',
>| 's' represent the values 'New', 'Maintenance', 'Renovation', 'Not
>| Specified' respectively in another lookup table. When i want to select
>| a list of data, the sql is
>| "SELECT col1, colvalue FROM tbl1 LEFT JOIN tbl2 ON (tbl1.col1 =
>| tbl2.col2) LIMIT 0, 100".
>| tbl1 is main data table, tbl2 is lookup table, and both col1 and col2
>| column type isenum('n', 'm', 'r', 's'). colvalue column is 'New',
>| 'Maintenance', 'Renovation', 'Not Specified'.
>|
>| Assume both the col1 and col2 are indexed
>|
Use a modified option 2.
colvalue enum('New', 'Maintenance', 'Renovation', 'Not Specified')
default 'New'
No need for a second table.
<a rel="nofollow" style='text-decoration: none;' href="http://dev.mysql.com/doc/mysql/en/enum.html" target="_blank">http://dev.mysql.com/doc/mysql/en/enum.html</a>
---------------------------------------------------------------
jnorthau DeleteThis @yourpantsyahoo.com.au : Remove your pants to reply
--------------------------------------------------------------- >> Stay informed about: enum vs tinyint |
|
| Back to top |
|
 |  |
| Related Topics: | Best way to issue hundreds of inserts/updates??? - Using mysql 4.0.23- What is the best way to execute several (hundreds of) inserts and updates? Rather than issuing tons of individual inserts and updates, can I send the strings to a text file and then have mysql do them all?? IE : query.txt insert..
MySQL freezes, brings XP machine to a grinding halt - I've been using MySQL for a while for fairly light database development on my XP machine. Currently, I am just starting a new project and have experienced some big problems with MySQL today both on my office machine and at home where running a particular...
login as user 'root' but do not have root privlages and my.. - Hi gang: I'm experiencing a problem with MySQL -- I updated MySQL from version 4.1.0 to 4.1.10 and now when I login as root it doesn't show all the databases I should have access to, nor it doesn't recognize me being logged in as root (via..
FLUSH TABLES hangs if table is locked - Using FLUSH TABLES via the C query API mysql_query() hangs if the table is locked already. That is to say, nothing prevents me from running a LOCK TABLES twice; it won't tell me "it's already locked, don't try to run a FLUSH". Anyone know ...
Tool to convert DDL in graphical diagram? - Does anyone know of a tool that will create a graphical diagram from a DDL (SQL create script)? Preferable a free open-source tool. Thanks, A |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|