V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  JasonLaw  ›  全部回复第 31 页 / 共 36 页
回复总数  714
1 ... 23  24  25  26  27  28  29  30  31  32 ... 36  
2020-08-28 10:47:41 +08:00
回复了 JasonLaw 创建的主题 MySQL 为什么阿里巴巴的 Java 开发手册说 text 要独立出来一张表?
@Aresxue #27

https://dev.mysql.com/doc/refman/8.0/en/innodb-row-format.html#innodb-row-format-compact - Tables that use the COMPACT row format store the first 768 bytes of variable-length column values (VARCHAR, VARBINARY, and BLOB and TEXT types) in the index record within the B-tree node, with the remainder stored on overflow pages.

https://dev.mysql.com/doc/refman/8.0/en/optimize-character.html - If a table contains string columns such as name and address, but many queries do not retrieve those columns, consider splitting the string columns into a separate table and using join queries with a foreign key when necessary. When MySQL retrieves any value from a row, it reads a data block containing all the columns of that row (and possibly other adjacent rows). Keeping each row small, with only the most frequently used columns, allows more rows to fit in each data block. Such compact tables reduce disk I/O and memory usage for common queries.
2020-08-28 10:02:59 +08:00
回复了 JasonLaw 创建的主题 MySQL 为什么阿里巴巴的 Java 开发手册说 text 要独立出来一张表?
@Infernalzero #22 我在 6 楼已经说了我明白你所说的内容,可能我的题目取得有点不好,除了原文提到的问题,我遗漏了我最关心的问题,为什么使用 text 替换 varchar,后来我也加了附言。你知道为什么要使用 text 替换 varchar 吗?

还有,你说的“你缺乏了一些基础知识的理解”是什么?我想知道。
2020-08-28 07:56:02 +08:00
回复了 JasonLaw 创建的主题 MySQL 为什么阿里巴巴的 Java 开发手册说 text 要独立出来一张表?
@crclz 你在说什么?能够详细解释一下吗?
2020-08-27 23:30:35 +08:00
回复了 JasonLaw 创建的主题 MySQL 为什么阿里巴巴的 Java 开发手册说 text 要独立出来一张表?
@BQsummer #15

你说“用 text 一般是长度限制”,什么长度限制?我在 9 楼已经回复了关于 varchar 和 text 容量的问题,它们的最大容量是一样的。

关于“使用附加表存储 text”,如果不是顺序获取 clustered index 中的 index record 之类的话,其实根本没有什么影响,比如直接通过主键 id 获取唯一的一行数据的时候。
2020-08-27 19:53:30 +08:00
回复了 JasonLaw 创建的主题 MySQL 为什么阿里巴巴的 Java 开发手册说 text 要独立出来一张表?
@cnoder 你说“ varchar 会算在行记录 65535 字节中,text 不占用”,text 不占用是什么?能具体解释一下吗?
2020-08-27 18:46:25 +08:00
回复了 JasonLaw 创建的主题 MySQL 为什么阿里巴巴的 Java 开发手册说 text 要独立出来一张表?
@CRUD https://dev.mysql.com/doc/refman/8.0/en/string-type-syntax.html 关于 varchar:A variable-length string. M represents the maximum column length in characters. The range of M is 0 to 65,535. 关于 text:A TEXT column with a maximum length of 65,535 (216 − 1) characters.
2020-08-27 18:33:56 +08:00
回复了 JasonLaw 创建的主题 MySQL 为什么阿里巴巴的 Java 开发手册说 text 要独立出来一张表?
@statement 其实我是没怎么看的,因为它只说了应该怎么做,但是没有解释为什么这么做好,为什么这么做不好。
2020-08-27 18:31:48 +08:00
回复了 JasonLaw 创建的主题 MySQL 为什么阿里巴巴的 Java 开发手册说 text 要独立出来一张表?
@PopRain
@nekolr

我明白你们所说的,将不常用字段放在附加表可以让一页可以存储主表更多的纪录。可能我没有表达清楚我的问题,我最大的疑问是为什么要将 varchar 换为 text 呢?它们的表现基本是一样的。
2020-08-27 15:02:43 +08:00
回复了 JasonLaw 创建的主题 Docker 由 Docker Redis 组成的 Redis cluster 在 macOS 上无法成功创建
@windghoul #2
@whileFalse #3

我想确认一下我理解的是不是正确的。--network=host 不行是因为 macOS 不支持,单纯使用-p ${i}:${i} -p $((${i} + 10000)):$((${i} + 10000))替换--network=host 不行是因为 redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 中的 127.0.0.1 (因为它们这三个容器都有自己的“动态”IP 地址)。对吗?
2020-08-24 15:37:24 +08:00
回复了 JasonLaw 创建的主题 数据库 JDBC connection URL string 中的 serverTimezone 的作用到底是什么?
@yanyueio #1
@skai0dev #2

通过 @palfortime 在“MySQL 时间“不正确”问题 - V2EX”的回答 - https://www.v2ex.com/t/700563#reply15,我明白了为什么“在 connection URL string 中设置时区”会将所设置时区的时间存储到 MySQL ?明白了到底是哪里进行这样的处理的?。

https://github.com/mysql/mysql-connector-j/blob/79a4336f140499bd22dd07f02b708e163844e3d5/src/main/protocol-impl/java/com/mysql/cj/protocol/a/NativeProtocol.java#L2228 中,会获取到 connection URL string 中所设置的 serverTimezone,最后会设置 serverSession 的 serverTimeZone 。
2020-08-23 23:28:25 +08:00
回复了 JasonLaw 创建的主题 数据库 JDBC connection URL string 中的 serverTimezone 的作用到底是什么?
@skai0dev #2 我有点不太理解“Override detection/mapping of time zone. Used when time zone from server doesn't map to Java time zone”,可以具体解释一下吗?谢谢。
2020-08-23 21:47:29 +08:00
回复了 JasonLaw 创建的主题 数据库 MySQL 时间“不正确”问题
@palfortime 我不太明白你所说的“mysql 默认认为 CST 是美国那个时区”,我已经设置了时区为 Asia/Shanghai 了。
2020-08-23 13:48:37 +08:00
回复了 JasonLaw 创建的主题 数据库 MySQL 时间“不正确”问题
@petelin #9 关于使用什么数据类型存储时间,网上真的什么说法都有。下面是我找到的一些资料,希望对看到这个主题的人有所帮助。对于使用 BIGINT 存储时间,我暂时不太清楚那样子做的利弊,可能之后会尝试一下,看看它的利弊到底是什么。

integer - Should I use a big INT or regular INT in MySQL to store a timestamp? - Stack Overflow - https://stackoverflow.com/questions/2031228/should-i-use-a-big-int-or-regular-int-in-mysql-to-store-a-timestamp

mysql - DATETIME VS INT for storing time? - Stack Overflow - https://stackoverflow.com/questions/43705935/datetime-vs-int-for-storing-time

Should I use the datetime or timestamp data type in MySQL? - Stack Overflow - https://stackoverflow.com/questions/409286/should-i-use-the-datetime-or-timestamp-data-type-in-mysql

Adam D'Angelo's answer to What is the best way to store a timestamp in MySQL? - Quora - https://www.quora.com/What-is-the-best-way-to-store-a-timestamp-in-MySQL/answer/Adam-DAngelo
2020-08-22 21:06:34 +08:00
回复了 JasonLaw 创建的主题 数据库 MySQL 时间“不正确”问题
@xupefei #4
@xuanbg #5
@rockyou12 #6

通过在 connection URL string 中显式地设置时区( serverTimezone=Asia/Shanghai )解决了,原因是时区的不一致导致的,默认的时区应该是 UTC−05:00 。

Setting the MySQL JDBC Timezone In Spring Boot | Baeldung - https://www.baeldung.com/mysql-jdbc-timezone-spring-boot#param
2020-08-22 20:20:20 +08:00
回复了 JasonLaw 创建的主题 数据库 MySQL 时间“不正确”问题
@xupefei #1 `docker exec -it some-mysql mysql -u root -pmy-secret-pw`,然后执行`select now();`,其结果为`2020-08-22 20:19:13`。
2020-08-22 20:20:08 +08:00
回复了 JasonLaw 创建的主题 数据库 MySQL 时间“不正确”问题
`docker exec -it some-mysql mysql -u root -pmy-secret-pw`,然后执行`select now();`,其结果为`2020-08-22 20:19:13`。
2020-08-20 17:51:27 +08:00
回复了 JasonLaw 创建的主题 编程 如何使用 Spring Boot 来管理 Maven plugin 的版本?
2020-08-20 17:47:33 +08:00
回复了 JasonLaw 创建的主题 编程 如何使用 Spring Boot 来管理 Maven plugin 的版本?
@SoloCompany #1 我希望它的 parent 是内部的,而不是 Spring Boot 的,所以采用了<scope>import</scope>这种方式。现在的话,就是自己显示地设置 plugin 的版本。
2020-08-16 11:24:38 +08:00
回复了 JasonLaw 创建的主题 Docker Docker MySQL 如何设置事务隔离级别?
@samin 你说“ 由于 `binlog` 日志的原因,MySQL 的默认事务隔离级别是可重复读”,可以详细说明一下吗?具体是什么原因导致默认事务隔离级别为可重复读?
2020-08-08 14:27:23 +08:00
回复了 lixuda 创建的主题 MySQL mysql 删除一条数据后显示这个,大佬们这个怎么解决?
MySQL Bugs: #45670: Secondary auto-incremented primary fields on replicas end up with wrong value - https://bugs.mysql.com/bug.php?id=45670 说明了这个问题,也给出了解决方法,但是并没有说明为什么。

如果有人知道为什么的话,分享一下,提前谢谢了。
1 ... 23  24  25  26  27  28  29  30  31  32 ... 36  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3204 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 26ms · UTC 14:11 · PVG 22:11 · LAX 07:11 · JFK 10:11
Developed with CodeLauncher
♥ Do have faith in what you're doing.