Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
go-athenaの大量データ取得を速くした方法
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
muroon
April 19, 2021
Programming
400
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
go-athenaの大量データ取得を速くした方法
muroon
April 19, 2021
More Decks by muroon
See All by muroon
UZOUにおけるAerospike
muroon
0
300
GCにおけるパフォーマンス改善
muroon
0
920
Goの静的解析を使用してAPI Doc Linterをつくる
muroon
0
78
Cloude Spannerの主キーの設計
muroon
0
74
Other Decks in Programming
See All in Programming
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
2
780
AIの中の人になってみる
htkym
0
170
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
3
490
信頼性の目標を誰も求めてない
shubox
0
500
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
210
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
1
430
高専キャリア LT 発表内容
crysta1221
6
5.6k
個人開発基盤をまるごとCloudflareに引っ越して爆速で総合的体験を向上させた話
tinykitten
0
150
ソフトウェアラスタライザ
fadis
1
800
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
270
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
1.8k
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
2
290
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
The Curious Case for Waylosing
cassininazir
1
500
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
320
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
460
Building Adaptive Systems
keathley
44
3.2k
Writing Fast Ruby
sferik
630
63k
Become a Pro
speakerdeck
PRO
31
6.2k
Building AI with AI
inesmontani
PRO
1
1.2k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
240
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
We Are The Robots
honzajavorek
0
360
Transcript
go-athenaの⼤量データ取得 を速くした⽅法
⾃⼰紹介 muroon https://twitter.com/muroon01 https://github.com/muroon Speeeという会社で広告配信システムを開発 Go歴は3年くらい
go-athenaとは database/sqlパッケージのAthenaのdriver import ( "database/sql" _ "github.com/speee/go-athena" ) func main()
{ db, _ := sql.Open("athena", "db=default&output_location=s3://results") rows, _ := db.Query("SELECT url, code from cloudfront") for rows.Next() { var url string var code int rows.Scan(&url, &code) } }
AWS Athenaとは AWS Athenaはサーバレスな分析サービスで、S3に保存・蓄積し たデータに対してSQLクエリにてデータ取得を⾏えるサービスで す。 • S3にデータを保存 • SQL検索
特徴 • APIを介してSQL実⾏ • SQLの結果をCSVダウンロードすることも可能 • CTASテーブルを使って圧縮形式でデータを取得する⽅法もあ る • GZIP • SNAPPY(Parquet)
go-athenaの⻑所 database/sqlパッケージを使⽤することにより、Goの開発者に とって開発しやすい データ取得がより簡単にできる • AWS Go SDK(https://docs.aws.amazon.com/sdk-for- go/api/service/athena/)を使⽤した場合 •
aws-sdk-goのAPI仕様を別途理解 • 接続確⽴、SQL実⾏、結果取得それぞれAPIアクセスが必要
go-athenaの問題点 APIアクセスしかできないこと • 取得件数が約1000件を超えるとrows.Next()の内部で複数ネッ トワークIOが⾛る rows, _ := db.Query("SELECT url,
code from cloudfront") for rows.Next() { var url string var code int rows.Scan(&url, &code) } ① ② ① ② 約1000件を超えると複数回取得する。O(n)
CSV, GZIP DLモードを作成 Resultモードというものを設けてCSVダウンロード、GZIPダウン ロードを可能にする • APIモード(default) • DLモード •
GZIPモード O(1)のネットワークアクセス ② ② 圧縮データダウンロード DLモード GZIPモード ①
各モードのパフォーマンス • 少量の件数ではDLモード、APIモードが有効 • ⼤量の件数ではGZIP DLモードが⾮常に有効
Resultモードの使⽤⽅法 Open時に設定 # API Mode db, err := sql.Open(“Athena”,”db=xxx&…”) #
DL Mode db, err := sql.Open(“Athena”,”db=xxx&…&result_mode=dl") # GZIP DL Mode db, err := sql.Open("athena","db=xxx&…&result_mode=gzip") SQL毎に設定 # API Mode ctx = SetAPIMode(ctx) # DL Mode ctx = SetDLMode(ctx) # GZIP DL Mode ctx = SetGzipDLMode(ctx)
URL https://github.com/speee/go-athena • fork元(segmentio/go-athena)のOrganizationは 2年近くメンテ ナンスされてないよう… • メンテする予定がないならリポジトリのTransferを検討しても らえないかを交渉中
ご清聴ありがとうございました