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
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Teambox: Starting and Learning
jrom
133
8.8k
Being A Developer After 40
akosma
87
590k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Measuring & Analyzing Core Web Vitals
bluesmoon
4
130
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
The Pragmatic Product Professional
lauravandoore
31
6.3k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
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ʹআϩάΛ͍ΕΔͱָ ✦ ঢ়گʹԠͯ͡ɺదʹআํ๏ΛબΜͰ͍͖·͠ΐ͏