- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2018 08:44 PM
Dear All,
I am trying to increase the field length to some 3000 characters for a field.
Will it affect the Database storage space ?
If for some records, there is no values mentioned (Empty value in that field) will it occupy the same space in database ?
Kindly suggest any better way...
Thanks,
Francis Xavier K.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2018 11:15 PM
Hi Francis,
Did you know? -
ServiceNow use MySQL database at the back-end. More information can be found from the stats.do page and clicking "Open Source Software".
Below how field get represented at the database level in a MySQL database:
A field with a max length value less than or equal to 255 is designated as a 'CHAR' datatype in the database. The DB won't accept a max length greater than what you specify for these fields.
As soon as your max length is 256 or more however, the field changes to a 'VARCHAR' datatype.
In ServiceNow for 254 characters or less, the string field will be a single-line text field. Anything 255 characters or over will appear as a multi-line text box but difference is obvious when you look at them. For an instance running on MySQL, you have more flexibility on your own.
Take a look at the reference between ServiceNow field types and MySQL.
for example: CHAR will always occupy the number of bytes based on the length specified. So CHAR(5) field will always occupy 5 bytes doesn't matter what we have stored, like 'a', 'abcd' or 'abcde'.
Unlike CHAR, VARCHAR will only occupy the space based on the data stored, So for example if we have fields with VARCHAR(30) then, this will occupy the space based on the data we are going to store.One more thing with VARCHAR is, it also occupy the 1 or 2 bytes of length prefix. This 1 and 2 bytes are based on length of data we store. If data is less than 255 char then 1 Byte is used and for data larger than 255 char 2 bytes are occupies as the length prefix
Obviously, VARCHAR holds the advantage since variable-length data would produce smaller rows and, thus, smaller physical files.Since CHAR fields require less string manipulation because of fixed field widths, index lookups against CHAR field are on average 20% faster than that of VARCHAR fields.
In your case a VARCHAR will take up only 2 byte per column per row. These bytes are used to describe the length of the data in the actual cell. Now days with storage being so cheap, it doesn't really matter unless you're talking about hundreds of millions of rows.
Hope this helps you.
Thanks,
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2018 10:22 PM
Hi Francis,
As per your requirement , data base will allocate logical space of 3000 character for the field and on "Empty value" in the field will not consume database storage space.
Best practice of Servicenow: Max field length is upto 4000 character length.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2018 11:15 PM
Hi Francis,
Did you know? -
ServiceNow use MySQL database at the back-end. More information can be found from the stats.do page and clicking "Open Source Software".
Below how field get represented at the database level in a MySQL database:
A field with a max length value less than or equal to 255 is designated as a 'CHAR' datatype in the database. The DB won't accept a max length greater than what you specify for these fields.
As soon as your max length is 256 or more however, the field changes to a 'VARCHAR' datatype.
In ServiceNow for 254 characters or less, the string field will be a single-line text field. Anything 255 characters or over will appear as a multi-line text box but difference is obvious when you look at them. For an instance running on MySQL, you have more flexibility on your own.
Take a look at the reference between ServiceNow field types and MySQL.
for example: CHAR will always occupy the number of bytes based on the length specified. So CHAR(5) field will always occupy 5 bytes doesn't matter what we have stored, like 'a', 'abcd' or 'abcde'.
Unlike CHAR, VARCHAR will only occupy the space based on the data stored, So for example if we have fields with VARCHAR(30) then, this will occupy the space based on the data we are going to store.One more thing with VARCHAR is, it also occupy the 1 or 2 bytes of length prefix. This 1 and 2 bytes are based on length of data we store. If data is less than 255 char then 1 Byte is used and for data larger than 255 char 2 bytes are occupies as the length prefix
Obviously, VARCHAR holds the advantage since variable-length data would produce smaller rows and, thus, smaller physical files.Since CHAR fields require less string manipulation because of fixed field widths, index lookups against CHAR field are on average 20% faster than that of VARCHAR fields.
In your case a VARCHAR will take up only 2 byte per column per row. These bytes are used to describe the length of the data in the actual cell. Now days with storage being so cheap, it doesn't really matter unless you're talking about hundreds of millions of rows.
Hope this helps you.
Thanks,
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.