varchar 字段的声明大小对 PostgreSQL 有任何影响吗? [英] Does a varchar field's declared size have any impact in PostgreSQL?

查看:78
本文介绍了varchar 字段的声明大小对 PostgreSQL 有任何影响吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从性能的角度来看,VARCHAR(100) 是否比 VARCHAR(500) 更好?磁盘使用情况如何?

Is VARCHAR(100) any better than VARCHAR(500) from a performance point of view? What about disk usage?

今天谈论的是 PostgreSQL,而不是历史上某个时期的某个数据库.

Talking about PostgreSQL today, not some database some time in history.

推荐答案

它们是相同的.

来自 PostgreSQL 文档:

From the PostgreSQL documentation:

http://www.postgresql.org/docs/8.3/静态/数据类型字符.html

提示:没有性能这三种类型的区别,除了增加存储空间时使用空白填充类型,以及一些额外的周期来检查长度时存储到长度受限的柱子.虽然字符(n)有在其他一些方面的性能优势数据库系统,它没有这样的PostgreSQL 的优势.多数情况情况文本或字符变化应该改用.

Tip: There are no performance differences between these three types, apart from increased storage size when using the blank-padded type, and a few extra cycles to check the length when storing into a length-constrained column. While character(n) has performance advantages in some other database systems, it has no such advantages in PostgreSQL. In most situations text or character varying should be used instead.

这里他们在讨论 char(n)、varchar(n) 和 text (= varchar(1G)) 之间的区别.官方说法是 varchar(100) 和 text(非常大的 varchar)没有区别.

Here they are talking about the differences between char(n), varchar(n) and text (= varchar(1G)). The official story is that there is no difference between varchar(100) and text (very large varchar).

这篇关于varchar 字段的声明大小对 PostgreSQL 有任何影响吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆