Skip to Content
Trino 权威指南:原书第2版
book

Trino 权威指南:原书第2版

by Matt Fuller, Manfred Moser, Martin Traverso
July 2023
Intermediate to advanced
278 pages
5h 40m
Chinese
China Machine Press
Content preview from Trino 权威指南:原书第2版
高级
SQL
特性
|
187
记住,
Trino
不是为
OLTP
查询而设计的,它不适合为公司的分类账生成绝对准确的
报表。然而,对于
OLAP
使用场景,只需了解趋势而无须完全准确的结果分析,使用
Trino
是可以接受并满足要求的。
Trino
提供了两个主要的近似函数:
approx_distinct
approx_percentile
Trino
使用
HyperLogLog
算法来实现
approx_distinct
函数。在数据分析中,统计不同
行的数量是一个非常常见的查询。例如,你可能想统计日志的不同用户
ID
IP
地址的
数量,以了解某天、某月或某年有多少用户访问了你的网站。由于用户可能多次访问你
的网站,因此,简单地统计日志中的条目数是行不通的。你需要找到不同的用户数,这
就要求你将每个用户的多次访问记录仅计为一次。为此,你需要在内存中保存一个结
构,这样就可以不用重复计算了。对于海量数据,这种方法就变得不切实际并且很慢,
HyperLogLog
提供了另一种方法,本书不会讨论具体算法。
为了实现近似不同的结果,
Trino
提供了
HyperLogLog
HLL
)数据类型,用户也可以使
用它。因为
Trino
提供
HyperLogLog
作为数据类型,这意味着它可以存入表中。这非常
有价值,因为你可以存储计算结果,以便以后再合并。假设你的数据是按天划分的,每
天你可以为当天的用户创建一个
HyperLogLog
结构并存储。然后,当你想计算近似基数
时,可以将
HyperLogLog
合并到一起得出结果。
9.19
窗函数
Trino
支持使用 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

What Successful Brick-and-Mortar Retailers Get Right

What Successful Brick-and-Mortar Retailers Get Right

Rob Angell
Three Essentials for Agentic AI Security

Three Essentials for Agentic AI Security

Paolo Dal Cin, Daniel Kendzior, Yusof Seedat, Renato Marinho
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer

Publisher Resources

ISBN: 9787111731603