When you set the text length of an attribute greater than 2000, the text will be stored as NVARCHAR(MAX) in a SQL Server Database. This can impact performance and database storage. However, I would like to understand the difference between setting the length to 50 characters versus 2000 characters. For example, consider a scenario where a text attribute is configured with a length of 2000 characters, but all the records contain fewer than 100 characters. In such cases, does the database still allocate 2000 characters of space for each record? Does fetching the data take longer? If not, why wouldn't you always set the text lenght to 2000?
Some tests were done in this article: https://stackoverflow.com/questions/8295131/best-practices-for-sql-varchar-column-length
Note that it is an old thread, I am not sure if this performance difference still holds. Feel free to dive in the documentation yourself.
Besides, there are some other arguments to define the attribute length with a character limit fewer than 2000. For example:- When scaffolding an input using the database attribute automatically sets the max-length to the right value. Just like the Mandatory property does not do anything on a database level for text attributes. - It makes understanding the code much easier when reviewed by another developer, or by yourself later. It will make it easier to understand what type of data to expect.- It helps finding bugs in an earlier stage, should you receive a value longer than the length that you expect.
There are probably more reasons to think of.
Hi,
See here how OutSystems Text attributes are mapped to MS Sql and Oracle DB data types:
https://success.outsystems.com/documentation/11/reference/outsystems_language/data/database_reference/database_data_types/
And here more information on the best practise around large text:
https://success.outsystems.com/documentation/best_practices/performance_and_monitoring/performance_best_practices_data_model/#Isolate_large_text_and_binary_data
-- Daniel