Menu

Why Your API Feels Slow (It’s Not Your Backend)
📰

Why Your API Feels Slow (It’s Not Your Backend)

DEV Community: database·Emmaculate Jane Akinyi Odhiambo·about 13 hours ago
#mSRuce9c
#devtodatabase#devto#dev#database#number
Reading 0:00
15s threshold

Do you know that your system is not slow just because of the language that you're using, or even the framework? Sometimes it's your database, because it's reading every single row just to find one record. So how do we fix that?

Number 1: indexing. Think of an index like the index at the back of your book. Without it, your database will be scanning row by row by row by row until it finds what you asked for. With an index, it gets a faster path directly to your data, which is easier. Mbona uchoke your database?

Number 2: pagination. If you have 1 million users—now why, explain to me why—would you be fetching all 1 million of them? Fetch 70. Hiyo 70 ingine, pole pole, you know? Number 3: caching. If 1,000 users keep asking for the same data, you are not supposed to be hitting your database every single time. Just store the frequently requested results in a fast cache. Like Redis, and serve them from there. And finally, partitioning. When a table becomes massive, split it into logical sections.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.