postgresql 的 text 类型是不是很方便

244 天前
 pxiphx891

我公司用的是 mysql ,我自己使用过 postgresql ,我感觉日常使用上,这两个没有什么不同。但是对我来说,postgres 有一个优势:它的 text 类型不需要指定长度,而且根据这个文档

There is no performance difference among these three types, apart from increased storage space when using the blank-padded type, and a few extra CPU cycles to check the length when storing into a length-constrained column. While character(n) has performance advantages in some other database systems, there is no such advantage in PostgreSQL; in fact character(n) is usually the slowest of the three because of its additional storage costs. In most situations text or character varying should be used instead.

这个不需要指定长度的类型更被推荐使用。 我平时创建的表,大部分字段其实都是字符串类型,不用思考这个字段有多长,这不是一件非常方便的事情吗?为什么新项目选型的时候,大家还要用 mysql 呢

863 次点击
所在节点    问与答
5 条回复
zzzkkk
244 天前
postsql 太严密了 groupby 时好像每个字段都要出现在 select 里面
我现在还把 mysql 的 sql_mode 置空
lanlanye
244 天前
可能是习惯吧……我是觉得 pg 好用很多
des
244 天前
@zzzkkk 也就低版本 mysql 这样了
newaccount
244 天前
因为 ilike 才不区分大小写、因为 collation 配置、因为 MySQL 可以无脑覆盖升级、因为其他人对这个数据库的熟悉程序

自己用当然怎么爽怎么来;团队里使用,还是得选择更傻瓜无脑式的,毕竟总有人变着花儿的弄点幺蛾子出来
troywinter
243 天前
pg 的优点远不止这些,多样的扩展类型对很多复杂业务有很好的支持,最近七八年工作的几家公司都在用 pg ,性能确实非常稳定

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/972976

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX