<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>PostgreSQL on Prateek Sharma</title>
		<link>https://prateeksharma.me/tags/postgresql/</link>
		<description>Recent content in PostgreSQL on Prateek Sharma</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Sun, 30 Aug 2026 00:00:00 +0000</lastBuildDate>
		
			<atom:link href="https://prateeksharma.me/tags/postgresql/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Composite index column order should match the query, not the schema</title>
				<link>https://prateeksharma.me/notes/index-column-order-should-match-the-filter/</link>
				<pubDate>Sun, 30 Aug 2026 00:00:00 +0000</pubDate>
				<guid>https://prateeksharma.me/notes/index-column-order-should-match-the-filter/</guid>
				<description>&lt;p&gt;In the &lt;a href=&#34;https://prateeksharma.me/projects/tts-study-assistant/&#34;&gt;TTS Study Assistant&lt;/a&gt;&#xA; notes table, queries&#xA;filter by &lt;code&gt;user_id&lt;/code&gt; always and &lt;code&gt;domain&lt;/code&gt; often, so the index is declared in that&#xA;order:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ff7b72&#34;&gt;CREATE&lt;/span&gt;&lt;span style=&#34;color:#6e7681&#34;&gt; &lt;/span&gt;&lt;span style=&#34;color:#ff7b72&#34;&gt;INDEX&lt;/span&gt;&lt;span style=&#34;color:#6e7681&#34;&gt; &lt;/span&gt;idx_uid_did&lt;span style=&#34;color:#6e7681&#34;&gt; &lt;/span&gt;&lt;span style=&#34;color:#ff7b72&#34;&gt;ON&lt;/span&gt;&lt;span style=&#34;color:#6e7681&#34;&gt; &lt;/span&gt;notes(user_id,&lt;span style=&#34;color:#6e7681&#34;&gt; &lt;/span&gt;&lt;span style=&#34;color:#ff7b72&#34;&gt;domain&lt;/span&gt;);&lt;span style=&#34;color:#6e7681&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;A composite index is only fully useful as a left-prefix: this index serves&#xA;&lt;code&gt;WHERE user_id = ?&lt;/code&gt; and &lt;code&gt;WHERE user_id = ? AND domain = ?&lt;/code&gt;, but not&#xA;&lt;code&gt;WHERE domain = ?&lt;/code&gt; alone. The rule of thumb is to order columns by how the&#xA;queries actually filter — most selective / most-always-present first — not by&#xA;declaration order in the table, and not alphabetically.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Tidylnk</title>
				<link>https://prateeksharma.me/projects/tidylnk/</link>
				<pubDate>Sun, 23 Aug 2026 00:00:00 +0000</pubDate>
				<guid>https://prateeksharma.me/projects/tidylnk/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://admin.tidylnk.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Tidylnk&lt;/a&gt;&#xA; is a URL shortener I built to have a&#xA;simple, self-hosted alternative to the usual third-party link shorteners, with an&#xA;admin panel to manage and track links.&lt;/p&gt;&#xA;&lt;h2 id=&#34;tech-stack&#34;&gt;Tech stack&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Backend&lt;/strong&gt; — Go, serving the redirect and link-management APIs.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Frontend&lt;/strong&gt; — a React admin panel for creating, organizing, and tracking&#xA;shortened links.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Storage&lt;/strong&gt; — PostgreSQL as the primary datastore for link records, with Redis&#xA;on the redirect hot path for fast lookups.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Deployment&lt;/strong&gt; — backend and database containerized with Docker and deployed on&#xA;Railway.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;why-i-built-it&#34;&gt;Why I built it&lt;/h2&gt;&#xA;&lt;p&gt;I wanted a link shortener I fully controlled — no reliance on a third party&amp;rsquo;s&#xA;uptime, rate limits, or analytics restrictions — and a project to exercise Go and&#xA;Redis together on a workload where caching genuinely matters: redirect latency.&lt;/p&gt;</description>
			</item>
			<item>
				<title>TTS Study Assistant</title>
				<link>https://prateeksharma.me/projects/tts-study-assistant/</link>
				<pubDate>Mon, 15 Jan 2024 00:00:00 +0000</pubDate>
				<guid>https://prateeksharma.me/projects/tts-study-assistant/</guid>
				<description>&lt;p&gt;The TTS Study Assistant lets you select text on any webpage, save it as a note,&#xA;hear it read aloud, and summarize it with AI for review. It&amp;rsquo;s a Chrome extension&#xA;(Manifest V3), a Go/Fiber backend, and a React admin panel.&lt;/p&gt;&#xA;&lt;h2 id=&#34;architecture&#34;&gt;Architecture&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Backend (Go)&lt;/strong&gt; — Fiber for HTTP, PostgreSQL via GORM, JWT auth, OpenAI for&#xA;summarization, deployed on Railway in a Docker container.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Frontend (React + TypeScript)&lt;/strong&gt; — Vite build, React Query + Context for&#xA;state, deployed on Vercel.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Extension&lt;/strong&gt; — Manifest V3 service worker, Chrome Storage API for local state,&#xA;Chrome TTS API for playback, content scripts for text selection.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;decisions-worth-noting&#34;&gt;Decisions worth noting&lt;/h2&gt;&#xA;&lt;h3 id=&#34;source-based-token-lifetimes&#34;&gt;Source-based token lifetimes&lt;/h3&gt;&#xA;&lt;p&gt;Web sessions and extension sessions have very different UX expectations, so the&#xA;access-token lifetime depends on where the request comes from:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Emission Critical</title>
				<link>https://prateeksharma.me/experience/emission-critical/</link>
				<pubDate>Sun, 01 May 2022 00:00:00 +0000</pubDate>
				<guid>https://prateeksharma.me/experience/emission-critical/</guid>
				<description>&lt;p&gt;Emission Critical is a B2B SaaS platform for enterprise carbon footprint and&#xA;sustainability tracking. I led the backend: the data model, the APIs, and the&#xA;computation engine.&lt;/p&gt;&#xA;&lt;h2 id=&#34;engineering-areas&#34;&gt;Engineering areas&lt;/h2&gt;&#xA;&lt;h3 id=&#34;multi-tenant-platform&#34;&gt;Multi-tenant platform&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Architected a &lt;strong&gt;multi-tenant PostgreSQL schema&lt;/strong&gt; with tenant-level data&#xA;isolation.&lt;/li&gt;&#xA;&lt;li&gt;Integrated &lt;strong&gt;Auth0&lt;/strong&gt; for identity and multi-tenant RBAC.&lt;/li&gt;&#xA;&lt;li&gt;Streamlined data ingestion through Excel parsing and automated &lt;strong&gt;AWS S3&lt;/strong&gt;&#xA;pipelines.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;carbon-accounting-engine&#34;&gt;Carbon accounting engine&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Designed the engine for full &lt;strong&gt;Scope 1, 2, and 3&lt;/strong&gt; emissions tracking and&#xA;product carbon footprints.&lt;/li&gt;&#xA;&lt;li&gt;Cut computation latency ~50% and improved throughput a further ~30% with&#xA;better indexing and batch processing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;search-and-lookups&#34;&gt;Search and lookups&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Built parsers and &lt;strong&gt;Meilisearch&lt;/strong&gt;-backed full-text search over public emission&#xA;factor databases.&lt;/li&gt;&#xA;&lt;li&gt;Exposed REST APIs for emission-factor lookups feeding downstream carbon&#xA;computation.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;observability&#34;&gt;Observability&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Stood up observability with &lt;strong&gt;OpenTelemetry&lt;/strong&gt;, SigNoz, and Kubernetes-native&#xA;logging for real-time diagnostics.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;stack&#34;&gt;Stack&lt;/h2&gt;&#xA;&lt;p&gt;NestJS · TypeScript · PostgreSQL · Auth0 · Meilisearch · AWS · Kubernetes ·&#xA;OpenTelemetry&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
