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
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
KATA
mclloyd
29
14k
For a Future-Friendly Web
brad_frost
175
9.4k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Making the Leap to Tech Lead
cromwellryan
133
9k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
Into the Great Unknown - MozCon
thekraken
33
1.5k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.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ʹআϩάΛ͍ΕΔͱָ ✦ ঢ়گʹԠͯ͡ɺదʹআํ๏ΛબΜͰ͍͖·͠ΐ͏