Good morning all
I am looking for ways to optimize a database.
I have used CHAR field types for the database.
I took a look at the VARCHAR field type.
According to the documentation, VARCHAR only uses the size that it needs unlike CHAR that pads the field to the full width.
Therefore you would expect a table with a VARCHAR field to have less size on disk for a comparative example.
I created 2 tables with 2 fields each - autoinc ID field and character field width 100
One of the tables the character field is VARCHAR the other CHAR
I added 10k records to each with just one character in the text field.
Other than a minor difference of size, the size on disk was the same, about 10mb.
So what good is a varchar field if it does not save size on disk, is there something I am missing?
Other than the text from varchar fields not requiring TRIM() etc?
I am looking for ways to optimize a database.
I have used CHAR field types for the database.
I took a look at the VARCHAR field type.
According to the documentation, VARCHAR only uses the size that it needs unlike CHAR that pads the field to the full width.
Therefore you would expect a table with a VARCHAR field to have less size on disk for a comparative example.
I created 2 tables with 2 fields each - autoinc ID field and character field width 100
One of the tables the character field is VARCHAR the other CHAR
I added 10k records to each with just one character in the text field.
Other than a minor difference of size, the size on disk was the same, about 10mb.
So what good is a varchar field if it does not save size on disk, is there something I am missing?
Other than the text from varchar fields not requiring TRIM() etc?