惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
罗磊的独立博客
博客园 - 【当耐特】
D
Docker
Y
Y Combinator Blog
L
LangChain Blog
博客园 - 三生石上(FineUI控件)
I
InfoQ
阮一峰的网络日志
阮一峰的网络日志
F
Fortinet All Blogs
J
Java Code Geeks
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
B
Blog
The GitHub Blog
The GitHub Blog
腾讯CDC
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
爱范儿
爱范儿
A
About on SuperTechFans
量子位
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

blag

SQLite prefixes its temp files with `etilqs_` - blag Setsum - order agnostic, additive, subtractive checksum - blag Oldest recorded transaction - blag Replacing a cache service with a database - blag SQLite commits are not durable under default settings - blag PSA: SQLite WAL checksums fail silently and may lose data - blag Rickrolling Turso DB (SQLite rewrite in Rust) - blag Collection of insane and fun facts about SQLite - blag How bloom filters made SQLite 10x faster - blag In search of a faster SQLite - blag Galloping Search - blag Building a distributed log using S3 (under 150 lines of Go) - blag Zero Disk Architecture - blag PSA: Most databases do not do checksums by default - blag PSA: SQLite does not do checksums - blag Disaggregated Storage - a brief introduction - blag Why does SQLite (in production) have such a bad rep? - blag SQLite Slaps - blag Now - blag Learning C - blag Snapshot Testing - blag Win: contribution to libSQL (SQLite) codebase - blag Errata in Hekaton MVCC paper - blag Internet is wholesome: MVCC edition - blag It is becoming difficult for me to be productive in Python - blag Introducing CaskDB – a project to teach you writing a key-value store - blag Recurse Center: Winter Break - blag Recurse Center Day 24: Hacking Go compiler to add a new keyword - blag Recurse Center Day 20: Django v4 upgrade (from v1) - blag Recurse Center Day 19 - blag
MongoDB secondary only index - blag
2022-05-22 · via blag

MongoDB officially does not allow adding secondary only indexes in a replica set. However, there is one hacky way to achieve the same.

Why

Sometimes you might have requirements which may not be needed for the main application. An actual use case is when you want to run analytics (or use things like Metabase) but don’t want to change the primary schema.

How

Earlier, I discovered an odd behaviour with MongoDB replica set and indexes. I thought one could use a similar approach to add secondary only indexes, which is what people have been doing.

The procedure is almost similar to how MongoDB adds rolling indexes to replicas but slightly different.

  1. Add a new member to the replica set (or pick an existing one)
  2. Make this member a non-voting member. This step is essential because we never want this member to become a primary, ever.
  3. Remove the member from the replica set - instructions
  4. Add the indexes you need
  5. Add the member back to the replica set
  6. Now connect to only this instance for analytics or other purposes

You might need to repeat steps 3-5 if you want to add new indexes.

References

  1. Bunch of Jira tickets - 1, 2
  2. Stackoverflow - 1, 2
  3. My previous blog post where I discovered that you can add duplicate records on an unique index