Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
論理削除と、そこでのElasticsearch活用 | 論理削除 Casual Talks #...
Search
misoobu
August 31, 2015
9
20k
論理削除と、そこでのElasticsearch活用 | 論理削除 Casual Talks #1 / soft_delete
イベント: 論理削除 Casual Talks #1 : ATND
https://atnd.org/events/68902
発表者:
https://twitter.com/misoobu
misoobu
August 31, 2015
Tweet
Share
More Decks by misoobu
See All by misoobu
サーバーとは。(あとゲーム) / server
misoobu
0
71
平和なエンジニア生活を送りたい
misoobu
0
800
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
Docker and Python
trallard
40
3.1k
A Philosophy of Restraint
colly
203
16k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Building an army of robots
kneath
302
43k
Designing for humans not robots
tammielis
250
25k
It's Worth the Effort
3n
183
27k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
Side Projects
sachag
452
42k
Transcript
ཧআͱɺͦ͜Ͱͷ &MBTUJDTFBSDI׆༻ ཧআ$BTVBM5BMLT!NJTPPCV
ࣗݾհ ࣄ SBJMTΞϓϦΛͭͬͯ͘ӡ༻ ॴଐ υϦίϜʹʢࡀʙʣ ໊લ !NJTPPCVʢদ࡚ʣ ཧআΛͨ͘͞Μ͖ͯ͠·ͨ͠
͢͜ͱ ✦ ͓͜ͳ͖ͬͯͨཧআʹ͍ͭͯ ✦ ཧআΛΊɺϩάΛ&MBTUJDTFBSDIʹ ೖΕΔΑ͏ʹͨ͜͠ͱ আํ๏બͷࢀߟʹͯ͠Β͑Ε!
લஔ͖ ✦ ϚελʔσʔλͰͳ͍ ✦ ͨ͘͞Μ͋Δ ✦ আޙɺΞϓϦຊମ͔Βࢀর͠ͳ͍ɺ෮׆͠ͳ͍ ✦ ӡ༻্ɺޙ͔ΒআσʔλΛݟΕΔඞཁ͕͋Δ ͜͜Ͱɺআ͢ΔσʔλҎԼͷ݅ͷͷ
আ͢Δ࣌ͷํ๏ ✦ আϑϥά ✦ আςʔϒϧ ✦ &MBTUJDTFBSDIͰϩά
আϑϥά
আϑϥά ✦ 3%#͔ΒϨίʔυΛཧআ͢ΔͷͰͳ͘ɺ ʮআͷঢ়ଶʯΛ࣋ͨͤΔ ✦ ීஈͷࢀরͰɺআঢ়ଶͷϨίʔυΛӅ͢ ΫΤϦWJFXΛ͔ͭ͏ ✦ আͷঢ়ଶʹɺCPPMJOUɺEBUFUJNF͕ΘΕΔ
আϑϥάྫ user_comments id: int user_id: int comment: text deleted_at: datetime
ࢀর SELECT * FROM user_comments WHERE user_id = 1 AND deleted_at IS NULL; আ UPDATE user_comments SET deleted_at = NOW() WHERE id = 1;
আϑϥάར ✦ ςʔϒϧʹΧϥϜΛͭՃ͢Δ͚ͩ ✦ আͨ͠σʔλͷࢀর෮׆ָ͕ ʢ΄΅Βͳ͍ఆʜʣ ✦ %&-&5&ΑΓ61%"5&ͷํ͕ύϑΥʔϚϯε͕ ͍͍
আϑϥάܽ ✦ ςʔϒϧ༰ྔ͕૿Ճ͍͢͠ ✦ ΫΤϦ͕ඇײతʹͳΔ ✦ ࢀরͰ݅Ճɺআʹ61%"5& ✦ 3%#ʹΑͬͯɺ6/*26&*/%&9͕͍ʹ͍͘ ✦
3%#ͱͯ͠ɺઃܭ͕Ϗϛϣʔ
আςʔϒϧ
আςʔϒϧ ✦ ཧআͨ͠ϨίʔυΛɺͦͷ··ΞʔΧΠϒ༻ͷ ςʔϒϧʹҠ͢ ✦ ཤྺςʔϒϧͱݺΕΔͷɺࣅͨܗΛ ͱΔ͜ͱ͕͋Δ
আςʔϒϧྫ ίϝϯτΛআ͢Δ user_comments id: int user_id: int comment: text archived_user_comments
id: int user_id: int comment: text archived_at: datetime %&-&5& */4&35
আςʔϒϧྫ ΧʔυΛച٫͢Δ user_cards id: int user_id: int card_id: int level:
int user_card_sale_histories id: int user_id: int card_id: int level: int money: int sold_at: datetime %&-&5& */4&35
আςʔϒϧར ✦ ݩʹͳΔςʔϒϧͷ༰ྔ૿Ճ͠ʹ͍͘ ✦ আςʔϒϧͰύʔςΟγϣϯΛΔͱɺ ݹ͍σʔλΛָʹফͤΔ
আςʔϒϧܽ ✦ ֎෦Ωʔ੍͕͑ͳ͍
͜͜·Ͱͷ·ͱΊ ✦ আϑϥάਏ͍ ✦ আςʔϒϧѱ͘ͳ͍͕ʜଞͷखߟ͑Δ
আϩά
আϩά ✦ 3%#͔Βཧআ͠ɺআσʔλΛ ผ్ϩάͱͯ͠ه͢Δ ✦ 3%#ଆΛγϯϓϧʹͰ͖Δ ✦ ϩάʹɺ&MBTUJDTFBSDIΛ͍ͬͯΔ
&MBTUJDTFBSDIͱ ✦ ࢄυΩϡϝϯτετΞ ✦ 3&45+40/ ✦ Α͘ݟΔར༻ྫ ✦ શจݕࡧΤϯδϯ ✦
ϩάΛೖΕΔ ✦ ͍ͷͰɺ͔͜͜Β&4ͱলུදه͢Δ!
&4ʹϩάΛೖΕΔ আͨ͠σʔλΛ&4ʹೖΕΔ { "user_comment_deleted_log": { "properties": { "user_id": { "type":
"integer" }, "comment": { "type": "string" }, “deleted_at": { "type": "date" } } } } user_comments id: int user_id: int comment: text %&-&5& */4&35
&4Ͱͷσʔλઃܭ { "app_log_20150831": { "mappings": { "user_comment_deleted_log": { "properties": {
"user_id": { "type": "integer" }, "comment": { "type": "string" }, "deleted_at": { "type": "date" } } } } } } index RDBͷσʔλϕʔεΈͨ ͍ͳͭɻ ୯ҐͰindex͢Δɻ type RDBͷςʔϒϧ Έ͍ͨͳͭɻ छྨͰtypeΛ͚Δɻ JOEFYͱUZQFʢͱVTFS@JEʣΛࢦఆͯ͠ɺϩάΛऔΓग़͢ field RDBͷΧϥϜΈ͍ͨͳ ͭɻ
✦ ΞΫγϣϯͰ3%#ͷෳͷϨίʔυΛফ͢߹ɺ ϩά·ͱΊͯͭͰೖΕΔ ✦ ࣮ࡍɺVTFS@JEͳͲͷݕࡧͰ͍͍ͨͷҎ֎ͷ ϑΟʔϧυɺѹॖͯͭ͠ʹ·ͱΊΔ ✦ ༰ྔରࡦɺϚοϐϯάʢσʔλߏʣఆٛͷ ൚༻Խ ✦
VTFS@JEͰSPVUJOHͯ͠ύϑΥʔϚϯε্ &4Ͱͷσʔλઃܭ
&4ͷϩάͷࢀর ✦ ઐ༻ͷϥΠϒϥϦΛͭ͘ΓɺͦΕΛ௨͍ͯ͠Δ ✦ औಘͨ͠σʔλɺѹॖΛҙࣝͤͣɺ3%#ͱࣅͨ ײ֮Ͱ͑Δ
'MVFOUEͰɺઐ༻ͷϩά ϑΝΠϧΛऩू Hadoop Elasticsearch 'MVFOUE ϩάΛऩूͯ͠ཧͰ͖Δπʔϧ )BEPPQ ฒྻࢄॲཧΛ࣮ݱ͢ΔϛυϧΣΞ App App
App CBUDIͰ CVMLJOTFSU ΞϓϦ͔ΒೖΕͳ͍ߏ ϩά͕&4ʹ֨ೲ͞ΕΔ·Ͱ
)BEPPQ ूɾੳ &MBTUJDTFBSDI Ϣʔβʔ୯ҐͰͷϩάݕࡧ )BEPPQͱ&4ͷ͍͚
✦ 3%#ଆΛγϯϓϧʹग़དྷΔ ✦ 3%#ͷ༰ྔΛؾʹ͢Δ͜ͱ͕ݮΔ ✦ σʔλͷੵ͕͍͢͠ ✦ ৽ͨͳϩάͷՃָ͕ &4Ͱͷআϩάར
✦ আޙɺ&MBTUJDTFBSDI͔ΒݟΒΕΔΑ͏ʹͳΔ ·Ͱʹ͕͔͔࣌ؒΔ ✦ ڐ༰Ͱ͖ͳ͍ͱ͖ɺ3%#ΛͬͨΓɺ 3%#ͱ&MBTUJDTFBSDIΛ߹ΘͤͯͬͨΓ ✦ ৴པੑΛΑΓߴ͍ͨ͘͠ͱ͖ɺ3%#Λ͏ &4Ͱͷআϩάܽ
·ͱΊ ✦ ಛʹن͕େ͖Ίͩͱɺআϑϥάਏ͍ࣄ͕ଟ͍ ✦ &MBTUJDTFBSDIʹআϩάΛ͍ΕΔͱָ ✦ ঢ়گʹԠͯ͡ɺదʹআํ๏ΛબΜͰ͍͖·͠ΐ͏