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
muroon
April 19, 2021
Programming
410
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
310
GCにおけるパフォーマンス改善
muroon
0
930
Goの静的解析を使用してAPI Doc Linterをつくる
muroon
0
80
Cloude Spannerの主キーの設計
muroon
0
93
Other Decks in Programming
See All in Programming
ActionController meets Protocol Buffers
sorah
0
680
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
320
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
190
Next.js: The final boss of Web Performance
guaca
0
320
Jetpack Compose Mechanisms
skydoves
3
860
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
200
🇪🇸 React Alicante 2026 (Workshop)
ythecombinator
PRO
0
100
No More NoSuchMethodError
exoego
1
110
Domain-Driven Transformation
hschwentner
2
2.3k
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
2
1.2k
contenteditable と日本語入力に向き合う
colorful12
0
210
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
360
Featured
See All Featured
Game over? The fight for quality and originality in the time of robots
wayneb77
1
310
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
610
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3.1k
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
490
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1.1k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.9k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
47k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
A Soul's Torment
seathinner
8
3.8k
A designer walks into a library…
pauljervisheath
211
25k
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を検討しても らえないかを交渉中
ご清聴ありがとうございました