<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Uddipan Bhattacharyya</title>
    <description>The latest articles on DEV Community by Uddipan Bhattacharyya (@uddipan_bhattacharyya).</description>
    <link>https://dev.to/uddipan_bhattacharyya</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4049767%2F496d7c81-a01a-4d8c-a256-dac0806a94b8.jpg</url>
      <title>DEV Community: Uddipan Bhattacharyya</title>
      <link>https://dev.to/uddipan_bhattacharyya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/uddipan_bhattacharyya"/>
    <language>en</language>
    <item>
      <title>The Day I Learned to Respect Database Indexes (The Hard Way)</title>
      <dc:creator>Uddipan Bhattacharyya</dc:creator>
      <pubDate>Mon, 27 Jul 2026 15:17:43 +0000</pubDate>
      <link>https://dev.to/uddipan_bhattacharyya/the-day-i-learned-to-respect-database-indexes-the-hard-way-29k9</link>
      <guid>https://dev.to/uddipan_bhattacharyya/the-day-i-learned-to-respect-database-indexes-the-hard-way-29k9</guid>
      <description>&lt;p&gt;In 2021, I graduated from my university and joined a startup as its first employee. That time, I learned a lot of things. I picked up the full stack from scratch, Flutter, Node.js, MongoDB, all of it. I learned fast and I was building things on my own within a few months.&lt;/p&gt;

&lt;p&gt;But there was one thing nobody told me to learn, and I never thought about it myself, database optimization.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Launch Was Three Days Away
&lt;/h2&gt;

&lt;p&gt;The company got a big project, and we worked on it for months. One day, we found out the launch was only three days away.&lt;/p&gt;

&lt;p&gt;The app had three levels of users. The lowest level users were added by us directly, and as part of that work, I uploaded more than 4 lakh user accounts into the database before the launch.&lt;/p&gt;

&lt;p&gt;The plan for the event was simple. On launch day, the mid level users would sign up on their own, live, in front of everyone.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Server Started Crashing
&lt;/h2&gt;

&lt;p&gt;Launch day came. The mid level users started registering.&lt;/p&gt;

&lt;p&gt;After about 50 people signed up, the server began to crash.&lt;/p&gt;

&lt;p&gt;We had no way of knowing how many people would try to register that day, so we never scaled the database server beforehand. To make it worse, we were running the database on an AWS free tier EC2 instance.&lt;/p&gt;

&lt;p&gt;While the server kept crashing, I checked everything I could think of. That's when I noticed it, the CPU was sitting at 100%.&lt;/p&gt;

&lt;p&gt;Then it hit me. I had forgotten to add an index for one important collection.&lt;/p&gt;

&lt;p&gt;With more than 4 lakh records in that collection, every single query, even a basic one like checking if a user exists, had to go through the whole collection one by one. No index meant no shortcut, just the CPU doing all the work, and it couldn't keep up.&lt;/p&gt;

&lt;h2&gt;
  
  
  Somehow, We Pulled It Off
&lt;/h2&gt;

&lt;p&gt;There was no time to panic. People were there, the launch was happening in real time, and we had to fix it fast. We scaled up the database server and added the missing index, and somehow it worked. The event went through successfully.&lt;/p&gt;

&lt;p&gt;But that moment stayed with me long after the day was over.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Learned From It
&lt;/h2&gt;

&lt;p&gt;Reading about indexes in a tutorial is one thing. Watching a live server crash in front of 200 people because of a missing one is a completely different lesson.&lt;/p&gt;

&lt;p&gt;Since that day, I always check for indexes first, on every project, no matter how small it is or how few users it has. I never want to feel that panic again.&lt;/p&gt;

&lt;p&gt;It has been 5 years now, and the project is still running, served more than 5 million users on it today. After that day, we kept optimizing many things, we added Redis and a few other tools, and now we run the whole system at a very low cost, around 0.05 rupees per user in our monthly bill.&lt;/p&gt;

</description>
      <category>database</category>
      <category>mongodb</category>
      <category>performance</category>
      <category>startup</category>
    </item>
  </channel>
</rss>
