asterisk2billing.org
http://forum.asterisk2billing.org/

Change CHAR to VARCHAR when both are used in same table.
http://forum.asterisk2billing.org/viewtopic.php?f=23&t=6855
Page 1 of 1

Author:  Sam [ Thu Dec 31, 2009 4:06 pm ]
Post subject:  Change CHAR to VARCHAR when both are used in same table.

Hi

Data type CHAR makes searches and querying for data faster but this benefit is canceled out when CHAR is used in the same table with VARCHAR. In cases where Data length are not the same in each record VARCHAR can save significant space over CHAR. For this reason its generally a good idea to use VARCHAR where there are no benefits of using CHAR.

The only time CHAR uses the same or less space than VARCHAR, is when all records have the exact data length in the CHAR field and the CHAR clolumn length is set the same as the data going in or not set more than one character greater.

The table cc_call_archive contains no VARCHAR so I assume this was to increase the search speed however this table may contain million of records and if this be the case the extra storage being used will be significant. Careful consideration should be used in this table on deciding which is best when using CHAR or VARCHAR.
Depending on how often searches are done on this table using VARCHAR might be a better choice.

The same consideration should be taken for any table likely to contain lots of records

Sam

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/