{"id":2941,"date":"2020-06-30T18:18:45","date_gmt":"2020-06-30T17:18:45","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=2941"},"modified":"2022-02-17T07:13:48","modified_gmt":"2022-02-17T07:13:48","slug":"text-or-varchar","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/mysql\/tables\/text-or-varchar","title":{"rendered":"TEXT or VARCHAR"},"content":{"rendered":"\n<h5 class=\"wp-block-heading\">Which is best?<\/h5>\n\n\n\n<p>Put simply, use a VARCHAR field instead of TEXT for columns between 255 and 65k characters if possible as it will lead to potentially fewer disk reads and less writes.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">VARCHAR<\/h5>\n\n\n\n<ul class=\"wp-block-list\"><li>Max size of 65535 characters<\/li><li>Uses 2+n bytes to store the value where n is the length of the stored string.<\/li><li>Stored inline within the table like other values<\/li><li>Can be handled in memory<\/li><li>Can be indexed<\/li><\/ul>\n\n\n\n<h5 class=\"wp-block-heading\">TEXT <\/h5>\n\n\n\n<ul class=\"wp-block-list\"><li>Max size of 65535 characters (more for mediumtext and longtext)<\/li><li>Uses 2+n bytes to store the value where n is the length of the stored string.<\/li><li>TEXT is <strong>stored off table<\/strong> with the table having a pointer to the location of the actual storage.<\/li><li>Using a TEXT column in a sort or in the results will <strong>require the use of a disk-based temporary table<\/strong> as it can&#8217;t be handled in RAM.<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Which is best? Put simply, use a VARCHAR field instead of TEXT for columns between 255 and 65k characters if possible as it will lead to potentially fewer disk reads and less writes. VARCHAR Max size of 65535 characters Uses 2+n bytes to store the value where n is the length of the stored string. [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[232,63],"tags":[],"class_list":["post-2941","post","type-post","status-publish","format-standard","hentry","category-columns-mysql","category-tables"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=2941"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2941\/revisions"}],"predecessor-version":[{"id":2944,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2941\/revisions\/2944"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=2941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=2941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=2941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}