<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Sql on Blogfolio Najib</title>
		<link>https://najib.id/en/tags/sql/</link>
		<description>Recent content in Sql on Blogfolio Najib</description>
		<generator>Hugo</generator>
		<language>en-US</language>
		
		
		
			<copyright>This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.</copyright>
		
		
			<lastBuildDate>Thu, 10 Sep 2026 16:50:44 +0700</lastBuildDate>
		
			<atom:link href="https://najib.id/en/tags/sql/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Hijrah Backend (5): The Query That Said &#39;Use My Index&#39;</title>
				<link>https://najib.id/en/writing/2026/hijrah-backend-05/</link>
				<pubDate>Thu, 10 Sep 2026 15:30:00 +0700</pubDate>
				<guid>https://najib.id/en/writing/2026/hijrah-backend-05/</guid>
				<description>&lt;p&gt;In &lt;a href=&#34;https://najib.id/en/writing/2026/hijrah-backend-02/&#34;&gt;episode two&lt;/a&gt;, the query was innocent, 78 milliseconds in the CLI while the endpoint burned 15 seconds. This episode is the mirror image: this time the query was truly guilty. But not because it was complex or ugly, it was guilty because one small function wrapper made it &lt;strong&gt;ignore an index built specifically for it&lt;/strong&gt; hehe~&lt;/p&gt;&#xA;&lt;h2 id=&#34;a-perfectly-designed-index-times-three&#34;&gt;A Perfectly Designed Index (Times Three) &lt;a href=&#34;#a-perfectly-designed-index-times-three&#34; class=&#34;tdln dimmer&#34;&gt;&lt;small&gt;#&lt;/small&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The victim: an endpoint counting alerts per device. Its alert table holds tens of millions of rows,&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; and on top of it sits a composite index: (date, device, alert type). Read the endpoint&amp;rsquo;s needs, &amp;ldquo;count alerts per device per type, within a date range&amp;rdquo;, and that index looks like it was built for exactly this query. Someone in the past understood the problem perfectly.&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
