Databases: Are "TEXT" fields less efficient than "varchar"?
performance, sql, variables
Solution
From Microsoft here
ntext, text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead.
When you use `varchar(max)` over text you can use it in the `WHERE` clause, because they work the same as their smaller counterparts, `varchar,nvarchar and varbinary`. Below is a small list of what should be used as opposed what was to be used:
- Use varchar(max) instead of text
- Use nvarchar(max) instead of ntext
- Use varbinary(max) instead of image
Problem
Is it less efficient to use TEXT than varchar in an SQL database? If so why? If not why would you not just always use TEXT? I'm not targetting a specific database here but oracle is probably the most relevant, although I'm testing on MySQL for the time being as part of a proof of concept.