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
A designer walks into a library…
pauljervisheath
204
24k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Writing Fast Ruby
sferik
628
61k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
96
Building Applications with DynamoDB
mza
91
6.1k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
BBQ
matthewcrist
85
9.4k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
How STYLIGHT went responsive
nonsquared
95
5.2k
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ʹআϩάΛ͍ΕΔͱָ ✦ ঢ়گʹԠͯ͡ɺదʹআํ๏ΛબΜͰ͍͖·͠ΐ͏