eldenmoon commented on code in PR #3253: URL: https://github.com/apache/doris-website/pull/3253#discussion_r2660159096
########## i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/basic-element/sql-data-types/semi-structured/VARIANT.md: ########## @@ -391,10 +391,34 @@ SELECT * FROM tbl WHERE v['str'] MATCH 'Doris'; | `VARCHAR` | ✔ | ✔ | | `JSON` | ✔ | ✔ | +## 宽列 + +当导入的数据中包含了大量的不同的 JSON key 时,VARAINT 的子列就会变多,达到一定程度就会出现性能下降问题。为了解决列数过多的问题,VARIANT 提供了两种机制。 + +1. 稀疏列机制:将所有的子列按照稀疏度排序,不稀疏的子列物化为独立子列,剩余的所有的稀疏的子列共同存放到稀疏列中。例如:设置 VARAINT 的最大子列数为 2048,导入的数据一万行中包含 5000个不同的 JSON key,在写入到磁盘文件上时,会根据每个 JSON key 实际存在的行数排序,行数最多的前2048列会物化成单独子列,剩余的2952列被存放到稀疏列中。 + - 稀疏列机制引入了 sharding 机制,例如指定 sharding count 为 10,在上述的例子中,磁盘上会存储10个稀疏列,平均每个稀疏列中有 295 个子列。 + +2. DOC编码机制:讲所有的子列物化为独立子列,并且将原始的 json 作为一个"存储字段"保存下来,用于查询整个 JSON。这个机制和Elasticsearch中的 stored fields 作用类似,在Elasticsearch中,可以把整个 DOC保存下来,用于取回整 DOC。 Review Comment: 缺少对doc编码优劣的描述, 参考下CK的文章和文档 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
