etrader Posted July 25, 2011 Share Posted July 25, 2011 I want to assign some values for each entry. Which plan is better to assist better mysql performance Plan A: Storing as "value1-value2-value3" in a column created by varchar(50); then I can process the values by explode() or Plan B: Storing values individually in three columns created by int(11) I want to know several small int() is better OR it is better to keep the number of columns lesser by having a larger column of varchar(), as I need to add "-" separator. Quote Link to comment https://forums.phpfreaks.com/topic/242750-a-long-column-or-several-short-columns-in-mysql/ Share on other sites More sharing options...
LeadingWebDev Posted July 25, 2011 Share Posted July 25, 2011 few short is better, than one long that will perform full text search in a bad case of using. Quote Link to comment https://forums.phpfreaks.com/topic/242750-a-long-column-or-several-short-columns-in-mysql/#findComment-1246803 Share on other sites More sharing options...
Muddy_Funster Posted July 25, 2011 Share Posted July 25, 2011 Rule of thumb - have a different field for each piece of data you want to store. Quote Link to comment https://forums.phpfreaks.com/topic/242750-a-long-column-or-several-short-columns-in-mysql/#findComment-1246807 Share on other sites More sharing options...
LeadingWebDev Posted July 25, 2011 Share Posted July 25, 2011 that all depends on usage of field in ur case. if u are planing to use later 'IN' inside ur query on a field u want to store implode(',',$var) perhaps this will be more relevant for you, otherwise if u gonna preform searches/filters on this data it is better to separate to few fields. Quote Link to comment https://forums.phpfreaks.com/topic/242750-a-long-column-or-several-short-columns-in-mysql/#findComment-1246818 Share on other sites More sharing options...
etrader Posted July 25, 2011 Author Share Posted July 25, 2011 No, I do not want to perform search, as they are numbers to define some parameters (even it can be only 0,1). And I never call them separetly, when I get them from mysql database, I need all of them. So you think it is better to store them in a single column to reduce the number of columns? Quote Link to comment https://forums.phpfreaks.com/topic/242750-a-long-column-or-several-short-columns-in-mysql/#findComment-1246901 Share on other sites More sharing options...
TeNDoLLA Posted July 25, 2011 Share Posted July 25, 2011 Kinda depends what you are up to, but without further info I would go with different columns for each data. Quote Link to comment https://forums.phpfreaks.com/topic/242750-a-long-column-or-several-short-columns-in-mysql/#findComment-1246915 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.