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
72
平和なエンジニア生活を送りたい
misoobu
0
810
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
Done Done
chrislema
182
16k
How STYLIGHT went responsive
nonsquared
96
5.3k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Optimising Largest Contentful Paint
csswizardry
33
3k
GitHub's CSS Performance
jonrohan
1030
460k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.1k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3.1k
Making Projects Easy
brettharned
116
6k
Automating Front-end Workflow
addyosmani
1366
200k
Documentation Writing (for coders)
carmenintech
67
4.5k
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ʹআϩάΛ͍ΕΔͱָ ✦ ঢ়گʹԠͯ͡ɺదʹআํ๏ΛબΜͰ͍͖·͠ΐ͏