आधी access pattern साठी design करा, नंतर partitioning + योग्य index/PK निवडा जेणेकरून कोणतीही एकच query एका लहान, बांधलेल्या slice ला स्पर्श करते — 1000 कोटी rows कधीही scan करत नाही. 1000 कोटी records वर 100ms खाली म्हणजे जलद disk नव्हे; तो working set अगदी लहान करण्याबद्दल आहे.
Query ─▶ Router ──▶ Partition (by tenant/time) ──▶ Index/PK lookup ─▶ ~thousands of rows
│ (prune 99.9% of data) (B-tree / sort key)
└─▶ Cache (Redis) ─▶ hit? return in <5ms
miss ▼
Columnar store (ClickHouse) for aggregates / scans
Access patterns सर्व काही ठरवतात
tech निवडण्याआधी विचारा: "युजर X च्या शेवटच्या 20 orders मिळवा" ही point/range query आहे — तुम्हाला partition आणि sort key नेमके त्याच्याशी जुळवायचे आहे. "या महिन्यात region नुसार revenue बेरीज करा" हा analytical scan आहे — row store चुकीचे साधन आहे. आधी query model करणे हेच चालणारे design आणि वाजवी दिसणारे पण full-scan करणारे design यांना वेगळे करते.
