<?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>Forem: Athreya aka Maneshwar</title>
    <description>The latest articles on Forem by Athreya aka Maneshwar (@lovestaco).</description>
    <link>https://forem.com/lovestaco</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1002302%2F5233b7df-6ee3-46b2-b8d7-1fafe103e8a3.jpg</url>
      <title>Forem: Athreya aka Maneshwar</title>
      <link>https://forem.com/lovestaco</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/lovestaco"/>
    <language>en</language>
    <item>
      <title>What Building with MCP Taught Me About Its Biggest Gap</title>
      <dc:creator>Athreya aka Maneshwar</dc:creator>
      <pubDate>Mon, 20 Apr 2026 16:58:14 +0000</pubDate>
      <link>https://forem.com/lovestaco/what-building-with-mcp-taught-me-about-its-biggest-gap-idl</link>
      <guid>https://forem.com/lovestaco/what-building-with-mcp-taught-me-about-its-biggest-gap-idl</guid>
      <description>&lt;p&gt;I spent the last few weeks wiring up MCP at my org, stitching a handful of internal tools (GitHub, Slack, Datadog) into a shared layer that multiple teams' AI agents could call into. &lt;/p&gt;

&lt;p&gt;Useful. Powerful. And, about a week in, slightly alarming.&lt;/p&gt;

&lt;p&gt;The same four or five "wait, doesn't MCP handle this?" questions kept coming up. &lt;em&gt;Who's allowed to call this tool? What happens if a tool returns 50MB of data? Where are we logging any of this? How do I give Team A read-only access when Team B needs write?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Turns out: MCP doesn't handle any of it. Not because it's broken, because that's not what it's for. &lt;/p&gt;

&lt;p&gt;MCP standardizes &lt;em&gt;how&lt;/em&gt; agents talk to tools. It says nothing about &lt;em&gt;who&lt;/em&gt; gets to, &lt;em&gt;how much&lt;/em&gt; they can pull, or &lt;em&gt;whether anyone's keeping receipts&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I can't drop my org's internal code into a blog post, so I rebuilt the same shape of problem in a tiny &lt;a href="https://github.com/lovestaco/mcp" rel="noopener noreferrer"&gt;public repo&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Three MCP servers, one Gemini-driven agent, one minimal gateway, all runnable in five minutes.  &lt;/p&gt;

&lt;h2&gt;
  
  
  So, MCP. What is it, again?
&lt;/h2&gt;

&lt;p&gt;A thirty-second version of MCP, straight from the official docs:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;MCP (Model Context Protocol) is an open-source standard for connecting AI applications to external systems. Think of it like a USB-C port for AI applications — a standardized way to plug data sources, tools, and workflows into Claude, ChatGPT, or whatever model you're wiring up.&lt;/p&gt;

&lt;p&gt;— &lt;a href="https://modelcontextprotocol.io/docs/getting-started/intro" rel="noopener noreferrer"&gt;modelcontextprotocol.io&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The mental model that finally made it click for me: &lt;strong&gt;MCP standardizes the plug, not the power grid.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Your agent speaks MCP. &lt;/p&gt;

&lt;p&gt;Your tools (GitHub, Slack, Datadog, your database) speak MCP. &lt;/p&gt;

&lt;p&gt;They meet in the middle and everything Just Works.&lt;/p&gt;

&lt;p&gt;Well. Almost everything.&lt;/p&gt;

&lt;h2&gt;
  
  
  The demo: one agent, three MCP servers, a Gemini brain
&lt;/h2&gt;

&lt;p&gt;To make this concrete, I built the smallest possible setup, a repo anyone can clone and run in five minutes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;GitHub MCP server&lt;/strong&gt; that exposes &lt;code&gt;get_readme&lt;/code&gt;, &lt;code&gt;get_latest_commit&lt;/code&gt;, &lt;code&gt;get_repo_files&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;Slack MCP server&lt;/strong&gt; that exposes &lt;code&gt;send_message&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;SQLite MCP server&lt;/strong&gt; that exposes &lt;code&gt;log_event&lt;/code&gt;, &lt;code&gt;get_logs&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;Gemini-driven agent&lt;/strong&gt; that picks a tool, calls it, summarizes the result, and posts to Slack&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Five processes, one loop. Here's what that actually looks like on screen:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpbi0eek9hy58inl0c05r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpbi0eek9hy58inl0c05r.png" alt="All five terminals running together" width="800" height="580"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Point the agent at a repo and off it goes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;taco@TCSIND-4shZvZXk:~/mcp&lt;span class="nv"&gt;$ &lt;/span&gt;node agent/agent.js
&lt;span class="o"&gt;[&lt;/span&gt;agent] starting one-loop run
&lt;span class="o"&gt;[&lt;/span&gt;agent] chosen tool: github.get_readme
&lt;span class="o"&gt;[&lt;/span&gt;agent] summary: Ragfolio is an AI-powered portfolio template that uses RAG to answer professional questions based on your resume data. It is built with a modern stack including React, FastAPI, and Google Gemini &lt;span class="k"&gt;for &lt;/span&gt;high-performance retrieval and generation.
&lt;span class="o"&gt;[&lt;/span&gt;agent] demo loop &lt;span class="nb"&gt;complete&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Try a bigger, more famous repo? Same agent, no code change:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;taco@TCSIND-4shZvZXk:~/mcp&lt;span class="nv"&gt;$ &lt;/span&gt;node agent/agent.js https://github.com/vercel/next.js
&lt;span class="o"&gt;[&lt;/span&gt;agent] starting one-loop run
&lt;span class="o"&gt;[&lt;/span&gt;agent] target repo: https://github.com/vercel/next.js
&lt;span class="o"&gt;[&lt;/span&gt;agent] objective: Summarize the project highlights &lt;span class="k"&gt;for &lt;/span&gt;a dev audience.
&lt;span class="o"&gt;[&lt;/span&gt;agent] chosen tool: github.get_readme
&lt;span class="o"&gt;[&lt;/span&gt;agent] summary: Next.js is a full-stack React framework designed &lt;span class="k"&gt;for &lt;/span&gt;building high-performance web applications with integrated Rust-based tooling. It extends the latest React features &lt;span class="k"&gt;while &lt;/span&gt;providing optimized build processes and a robust ecosystem &lt;span class="k"&gt;for &lt;/span&gt;enterprise-scale development.
&lt;span class="o"&gt;[&lt;/span&gt;agent] demo loop &lt;span class="nb"&gt;complete&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Slack confirms the summaries landed:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmb6y6ue587fgev1r3d3s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmb6y6ue587fgev1r3d3s.png" alt="Slack showing ragfolio and Next.js summaries" width="800" height="95"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Everything works. High-fives all around. I'm ready to ship this to teams.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu2t5l942efztd9lvmru7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu2t5l942efztd9lvmru7.png" alt="The " width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And then I actually think about what I just built.&lt;/p&gt;

&lt;h2&gt;
  
  
  What MCP quietly does &lt;em&gt;not&lt;/em&gt; give you
&lt;/h2&gt;

&lt;p&gt;MCP is a protocol. That's wonderful and that's also exactly the problem. Out of the box, vanilla MCP has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No auth.&lt;/strong&gt; Anyone who can reach port 4001 can call every tool on the GitHub server. In prod, that's a problem.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No RBAC.&lt;/strong&gt; Every caller gets every tool, or no tools.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No audit.&lt;/strong&gt; Unless you add logging to every server, by hand, there is no record of who called what. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No guardrails on outputs.&lt;/strong&gt; If a tool returns a 2MB README, your agent happily eats 2MB of its context window. If a tool returns &lt;code&gt;rm -rf /&lt;/code&gt;, your agent happily executes it too.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No shared policy layer.&lt;/strong&gt; Every team ends up copy-pasting the same "validate tool name, wrap in &lt;code&gt;{ output, error }&lt;/code&gt;" boilerplate, each with its own subtly different bugs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is not a knock on MCP. &lt;/p&gt;

&lt;p&gt;USB-C also doesn't come with a surge protector. &lt;/p&gt;

&lt;p&gt;Those are separate products for good reasons. &lt;/p&gt;

&lt;p&gt;But if you're running agents in an environment where the blast radius of "oops" is meaningful, you need that separate product.&lt;/p&gt;

&lt;p&gt;The obvious place for that product to live? A &lt;strong&gt;gateway&lt;/strong&gt;, sitting between every agent and every MCP server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting a tiny gateway in front of everything
&lt;/h2&gt;

&lt;p&gt;In my demo repo, the gateway is a single 90-line Express file (&lt;code&gt;gateway/gateway.js&lt;/code&gt;). It does three things. Together, they cover 80% of the complaints above.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. An allowlist — capability control in one &lt;code&gt;Set&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Every tool call is namespaced (&lt;code&gt;github.get_readme&lt;/code&gt;, &lt;code&gt;slack.send_message&lt;/code&gt;, &lt;code&gt;db.log_event&lt;/code&gt;). &lt;/p&gt;

&lt;p&gt;The allowlist is quite literally a JS &lt;code&gt;Set&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;TOOL_ALLOWLIST&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
  &lt;span class="nx"&gt;TOOL_NAMES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GITHUB_GET_README&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;TOOL_NAMES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;SLACK_SEND_MESSAGE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;TOOL_NAMES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DB_LOG_EVENT&lt;/span&gt;
&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If an agent (or a prompt-injected-into-misbehavior agent) tries to call &lt;code&gt;github.delete_repo&lt;/code&gt;, it never reaches the GitHub server. &lt;/p&gt;

&lt;p&gt;The gateway refuses in three lines, logs the attempt, and sends back a polite error.&lt;/p&gt;

&lt;p&gt;Notice what this &lt;em&gt;isn't&lt;/em&gt;: a prompt that says "please don't call delete_repo." &lt;/p&gt;

&lt;p&gt;Prompts are suggestions. &lt;/p&gt;

&lt;p&gt;Allowlists are rules.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. A guardrail — the content contract
&lt;/h3&gt;

&lt;p&gt;Some tools return unbounded blobs. &lt;/p&gt;

&lt;p&gt;READMEs in particular love to be 40KB of badges and marketing copy. &lt;/p&gt;

&lt;p&gt;The gateway has a hardcoded cap:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;tool&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;TOOL_NAMES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GITHUB_GET_README&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
  &lt;span class="nx"&gt;serverResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;output&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;createError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;README content exceeded 5000 characters&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's that guardrail earning its keep on a deliberately gnarly repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;taco@TCSIND-4shZvZXk:~/mcp&lt;span class="nv"&gt;$ &lt;/span&gt;node agent/agent.js https://github.com/juice-shop/juice-shop 
&lt;span class="o"&gt;[&lt;/span&gt;agent] starting one-loop run
&lt;span class="o"&gt;[&lt;/span&gt;agent] target repo: https://github.com/juice-shop/juice-shop
&lt;span class="o"&gt;[&lt;/span&gt;agent] objective: Summarize the project highlights &lt;span class="k"&gt;for &lt;/span&gt;a dev audience.
&lt;span class="o"&gt;[&lt;/span&gt;agent] chosen tool: github.get_readme
&lt;span class="o"&gt;[&lt;/span&gt;agent] first tool call failed: &lt;span class="o"&gt;{&lt;/span&gt;
  message: &lt;span class="s1"&gt;'Guardrail blocked response: README content exceeded 5000 characters'&lt;/span&gt;,
  details: null
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Juice Shop's README is enormous. &lt;/p&gt;

&lt;p&gt;Without the guardrail, my agent would've burned half its context on emoji-laden marketing. &lt;/p&gt;

&lt;p&gt;With the guardrail, the agent got a clean "nope, try something else" and my context window stayed intact.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8sqbszd33efzo0h3p122.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8sqbszd33efzo0h3p122.png" alt="Gandalf " width="641" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Logging — audit trail for free
&lt;/h3&gt;

&lt;p&gt;Every single call through the gateway i.e success, failure, allowlist rejection, guardrail block  gets recorded to SQLite via the &lt;code&gt;db.log_event&lt;/code&gt; tool. &lt;/p&gt;

&lt;p&gt;Best-effort, fire-and-forget, one &lt;code&gt;await&lt;/code&gt; in the middleware.&lt;/p&gt;

&lt;p&gt;Now when someone asks &lt;em&gt;"what did the agent do yesterday?"&lt;/em&gt; the answer is a query, not a shrug.&lt;/p&gt;

&lt;p&gt;That's it. &lt;/p&gt;

&lt;p&gt;That's the whole governance layer. &lt;/p&gt;

&lt;p&gt;An allowlist, a guardrail, a log  roughly 200 lines of Node, no framework, readable in a single sitting.&lt;/p&gt;

&lt;h2&gt;
  
  
  But a toy gateway is still a toy
&lt;/h2&gt;

&lt;p&gt;Here's where I have to be honest with myself. &lt;/p&gt;

&lt;p&gt;My gateway works for the demo. &lt;/p&gt;

&lt;p&gt;It would not survive contact with a real organization.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The allowlist is &lt;strong&gt;one &lt;code&gt;Set&lt;/code&gt; shared by everyone&lt;/strong&gt;. No per-team, per-agent, per-use-case scoping.&lt;/li&gt;
&lt;li&gt;Guardrails are &lt;strong&gt;hardcoded conditionals&lt;/strong&gt;. Adding a new one means a code change and a redeploy.&lt;/li&gt;
&lt;li&gt;Authentication is &lt;strong&gt;nonexistent&lt;/strong&gt;. Anyone who can &lt;code&gt;curl :3000/mcp&lt;/code&gt; is an agent now.&lt;/li&gt;
&lt;li&gt;Routing is &lt;strong&gt;three &lt;code&gt;localhost&lt;/code&gt; URLs in a map&lt;/strong&gt;. No service discovery, no health checks, no retries.&lt;/li&gt;
&lt;li&gt;Adding a new tool means &lt;strong&gt;editing three files&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Solving each of those is a weekend project. &lt;/p&gt;

&lt;p&gt;Solving all of them, operating them, and keeping them maintained as tools come and go across teams, that's a platform team's full-time job.&lt;/p&gt;

&lt;h2&gt;
  
  
  The feature I wish I'd built first: the Virtual MCP Server
&lt;/h2&gt;

&lt;p&gt;While researching what a grown-up version of this gateway looks like, I came across &lt;strong&gt;TrueFoundry's MCP Gateway&lt;/strong&gt; and specifically their concept of a &lt;strong&gt;Virtual MCP Server&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;It's one of those ideas that's obvious in retrospect and I'm mildly annoyed I didn't think of it first.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frart7msy3xnpuiedr2bj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frart7msy3xnpuiedr2bj.png" alt="Expanding-brain / galaxy-brain meme — panel 1: " width="500" height="701"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The idea:&lt;/p&gt;

&lt;p&gt;You have a bunch of real MCP servers, each exposing lots of tools. &lt;/p&gt;

&lt;p&gt;Some tools are safe. &lt;/p&gt;

&lt;p&gt;Some are dangerous. &lt;/p&gt;

&lt;p&gt;Some are fine for one team and a footgun for another.&lt;/p&gt;

&lt;p&gt;Rather than giving teams access to &lt;em&gt;whole servers&lt;/em&gt;, you compose a &lt;strong&gt;Virtual MCP Server&lt;/strong&gt;, a curated, custom, named collection of tools pulled from &lt;em&gt;whichever&lt;/em&gt; upstream servers you want.&lt;/p&gt;

&lt;p&gt;Concretely:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your &lt;strong&gt;&lt;code&gt;doc-summary-bot&lt;/code&gt;&lt;/strong&gt; Virtual MCP Server exposes just &lt;code&gt;github.get_readme&lt;/code&gt; and &lt;code&gt;slack.send_message&lt;/code&gt;. That's the full surface area.&lt;/li&gt;
&lt;li&gt;Your &lt;strong&gt;&lt;code&gt;release-bot&lt;/code&gt;&lt;/strong&gt; Virtual MCP Server exposes &lt;code&gt;github.create_release&lt;/code&gt;, &lt;code&gt;github.tag_commit&lt;/code&gt;, and &lt;code&gt;slack.send_message&lt;/code&gt; — but &lt;em&gt;not&lt;/em&gt; &lt;code&gt;github.delete_repo&lt;/code&gt;, even though the upstream GitHub server technically supports it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No new deployments.  &lt;/p&gt;

&lt;p&gt;The virtual server is just configuration on the gateway, and each one gets its own allowlist, its own guardrails, its own auth scope.&lt;/p&gt;

&lt;p&gt;This matters because of the failure mode it quietly prevents. &lt;/p&gt;

&lt;p&gt;Here's a solid demo video explaining &lt;a href="https://youtu.be/cZgc0qxDP2k?si=fm_lv8fRL1F4YaxN" rel="noopener noreferrer"&gt;Virtual MCP Server&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this looks like in a real workflow
&lt;/h2&gt;

&lt;p&gt;Let me walk through the kind of agent I'd actually want to run in production, a &lt;strong&gt;compliance automation bot&lt;/strong&gt;, operating entirely through a TrueFoundry MCP Gateway endpoint:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A PR merges to &lt;code&gt;main&lt;/code&gt;. A webhook wakes the agent.&lt;/li&gt;
&lt;li&gt;The agent calls &lt;code&gt;github.get_diff&lt;/code&gt; via its Virtual MCP Server. &lt;strong&gt;Authenticated&lt;/strong&gt;, not with a bare PAT pasted into an env var, but with a service token the gateway issued and can rotate.&lt;/li&gt;
&lt;li&gt;The diff comes back. The gateway's &lt;strong&gt;guardrail&lt;/strong&gt; notices it's 12,000 lines, well over the "unsupervised review" threshold  and &lt;strong&gt;pauses the run, requesting human approval&lt;/strong&gt; before continuing. (Try getting &lt;em&gt;that&lt;/em&gt; out of a lone MCP server.)&lt;/li&gt;
&lt;li&gt;A reviewer approves. The agent writes the diff plus metadata to MongoDB via &lt;code&gt;db.store_diff&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;It opens a Jira ticket via &lt;code&gt;jira.create_issue&lt;/code&gt;, linking back to the diff.&lt;/li&gt;
&lt;li&gt;It posts a summary to Slack via &lt;code&gt;slack.send_message&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Six tool calls. &lt;/p&gt;

&lt;p&gt;Four different upstream MCP servers. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One endpoint.&lt;/strong&gt; Every call authenticated. Every call logged to the audit trail. &lt;/p&gt;

&lt;p&gt;The single dangerous tool the agent isn't supposed to touch, even if a prompt injection convinces it to try it isn't &lt;em&gt;prompted against&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;It's simply &lt;strong&gt;not in the Virtual MCP Server&lt;/strong&gt;, so calling it is a 404, not a judgment call.&lt;/p&gt;

&lt;p&gt;That, to me, is the jump from protocol to platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;MCP gave us a clean, shared language for AI agents to talk to tools. &lt;/p&gt;

&lt;p&gt;That's a big deal, and it's easy to underrate how much of a pain this was &lt;em&gt;before&lt;/em&gt; MCP existed.&lt;/p&gt;

&lt;p&gt;But a shared language isn't a shared policy. &lt;/p&gt;

&lt;p&gt;If you're running more than one agent, or letting more than one team build agents, you will need the thing that sits between "call the tool" and "did we mean to let it call the tool." &lt;/p&gt;

&lt;p&gt;That thing is a gateway.&lt;/p&gt;

&lt;p&gt;You can build a toy version in an afternoon. &lt;/p&gt;

&lt;p&gt;My demo repo is proof. &lt;/p&gt;

&lt;p&gt;But for anything real — auth, RBAC, audit, per-scope capability boundaries, and the Virtual MCP Server trick  you want a platform that treats governance as the product, not the afterthought.&lt;/p&gt;

&lt;p&gt;Take a look at &lt;a href="https://www.truefoundry.com/" rel="noopener noreferrer"&gt;TrueFoundry's MCP Gateway&lt;/a&gt; and the Virtual MCP Server feature if you're at the "I'm giving real agents real tools and someone in security wants to talk to me" stage.&lt;/p&gt;

&lt;p&gt;If you build something interesting on top of either, I'd love to see it. Happy gatewaying.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>ai</category>
      <category>mcp</category>
    </item>
    <item>
      <title>Triggers in SQLite: Automating Logic Inside Your Database</title>
      <dc:creator>Athreya aka Maneshwar</dc:creator>
      <pubDate>Tue, 14 Apr 2026 18:19:58 +0000</pubDate>
      <link>https://forem.com/lovestaco/triggers-in-sqlite-automating-logic-inside-your-database-301b</link>
      <guid>https://forem.com/lovestaco/triggers-in-sqlite-automating-logic-inside-your-database-301b</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Maneshwar. I'm building git-lrc, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/em&gt;&lt;/p&gt; 

&lt;p&gt;So far, we’ve looked at how SQLite lets you query smarter (subqueries), structure cleaner (views), and control IDs (autoincrement).&lt;/p&gt;

&lt;p&gt;Now we move into something more powerful—something that lets your database react automatically.&lt;/p&gt;

&lt;p&gt;That’s where triggers come in.&lt;/p&gt;

&lt;p&gt;A trigger is code that runs automatically when something happens in your database.&lt;/p&gt;

&lt;p&gt;You don’t call it.&lt;br&gt;
You don’t manually execute it.&lt;br&gt;
It just runs behind the scenes.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Three Parts of a Trigger
&lt;/h2&gt;

&lt;p&gt;Every trigger is built on three things:&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Event (When it runs)
&lt;/h3&gt;

&lt;p&gt;This is what activates the trigger:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;INSERT&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;UPDATE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;DELETE&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  2. Condition (Should it run?)
&lt;/h3&gt;

&lt;p&gt;An optional check using a &lt;code&gt;WHEN&lt;/code&gt; clause.&lt;/p&gt;

&lt;p&gt;If the condition is false → trigger does nothing.&lt;/p&gt;
&lt;h3&gt;
  
  
  3. Action (What it does)
&lt;/h3&gt;

&lt;p&gt;The actual SQL logic:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;INSERT&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;UPDATE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;DELETE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SELECT&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Real-World Use Case: Preventing Invalid Data
&lt;/h2&gt;

&lt;p&gt;Imagine you're managing a banking system. &lt;/p&gt;

&lt;p&gt;You don’t want a user’s account balance to go negative accidentally. &lt;/p&gt;

&lt;p&gt;Instead of relying only on application code, you can enforce this rule directly in the database using a trigger.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TRIGGER&lt;/span&gt; &lt;span class="n"&gt;prevent_negative_balance&lt;/span&gt;
&lt;span class="k"&gt;BEFORE&lt;/span&gt; &lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="k"&gt;OF&lt;/span&gt; &lt;span class="n"&gt;balance&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;accounts&lt;/span&gt;
&lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="k"&gt;NEW&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;balance&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;BEGIN&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;RAISE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;ABORT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Balance cannot be negative'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;What’s happening here?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The trigger fires &lt;strong&gt;before&lt;/strong&gt; the balance is updated.&lt;/li&gt;
&lt;li&gt;It checks if the new balance is less than zero.&lt;/li&gt;
&lt;li&gt;If true, it aborts the operation with an error message.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This ensures your data remains consistent no matter where the update originates.&lt;/p&gt;
&lt;h2&gt;
  
  
  Keeping Track: Audit Logs with Triggers
&lt;/h2&gt;

&lt;p&gt;Another powerful use of triggers is maintaining an audit trail. &lt;/p&gt;

&lt;p&gt;For example, tracking changes made to sensitive data like salaries or account details.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TRIGGER&lt;/span&gt; &lt;span class="n"&gt;log_salary_update&lt;/span&gt;
&lt;span class="k"&gt;AFTER&lt;/span&gt; &lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="k"&gt;OF&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="k"&gt;BEGIN&lt;/span&gt;
    &lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;salary_audit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;employee_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;old_salary&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;new_salary&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;change_date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;OLD&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;OLD&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;NEW&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'now'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now every time a salary is updated:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The old and new values are recorded&lt;/li&gt;
&lt;li&gt;You get a timestamp of the change&lt;/li&gt;
&lt;li&gt;No manual logging required!&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  When Triggers Go Wrong
&lt;/h2&gt;

&lt;p&gt;While triggers are powerful, they can also introduce complexity if not used carefully.&lt;/p&gt;

&lt;p&gt;Here are a few pitfalls to watch out for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hidden logic&lt;/strong&gt;: Since triggers run automatically, it can be hard to debug unexpected behavior.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance impact&lt;/strong&gt;: Multiple triggers on large datasets can slow down operations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recursive triggers&lt;/strong&gt;: A trigger that modifies a table may unintentionally fire another trigger, creating loops.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Best practice: Keep triggers simple, focused, and well-documented.&lt;/p&gt;

&lt;p&gt;Triggers are like invisible guardians of your database, they watch, react, and enforce rules without being explicitly called. &lt;/p&gt;

&lt;p&gt;When used wisely, they reduce redundancy, improve consistency, and make your system more robust.&lt;/p&gt;

&lt;p&gt;But like any powerful tool, they demand discipline. &lt;/p&gt;

&lt;p&gt;Overuse or misuse can lead to confusion and performance issues. &lt;/p&gt;

&lt;p&gt;The key is balance: use triggers where they shine, and keep your logic transparent and maintainable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyzvpkxm9mga1pweneahx.png" alt="git-lrc" width="800" height="109"&gt;&lt;/a&gt; &lt;br&gt;
 *AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production. &lt;/p&gt;

&lt;p&gt;git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.* &lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use. &lt;/p&gt;

&lt;p&gt;⭐ Star it on GitHub: &lt;br&gt;
 &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/HexmosTech" rel="noopener noreferrer"&gt;
        HexmosTech
      &lt;/a&gt; / &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;
        git-lrc
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Free, Unlimited AI Code Reviews That Run on Commit
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div&gt;
&lt;p&gt;| &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.da.md" rel="noopener noreferrer"&gt;🇩🇰 Dansk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.es.md" rel="noopener noreferrer"&gt;🇪🇸 Español&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fa.md" rel="noopener noreferrer"&gt;🇮🇷 Farsi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fi.md" rel="noopener noreferrer"&gt;🇫🇮 Suomi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ja.md" rel="noopener noreferrer"&gt;🇯🇵 日本語&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.nn.md" rel="noopener noreferrer"&gt;🇳🇴 Norsk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.pt.md" rel="noopener noreferrer"&gt;🇵🇹 Português&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ru.md" rel="noopener noreferrer"&gt;🇷🇺 Русский&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.sq.md" rel="noopener noreferrer"&gt;🇦🇱 Shqip&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.zh.md" rel="noopener noreferrer"&gt;🇨🇳 中文&lt;/a&gt; |&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;img width="60" alt="git-lrc logo" src="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;/a&gt;
&lt;br&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;git-lrc&lt;/h1&gt;
&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Free, Unlimited AI Code Reviews That Run on Commit&lt;/h2&gt;
&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.producthunt.com/products/git-lrc?embed=true&amp;amp;utm_source=badge-top-post-badge&amp;amp;utm_medium=badge&amp;amp;utm_campaign=badge-git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt" width="200" src="https://camo.githubusercontent.com/87bf2d4283c1e0aa99e254bd17fefb1c67c0c0d39300043a243a4aa633b6cecc/68747470733a2f2f6170692e70726f6475637468756e742e636f6d2f776964676574732f656d6265642d696d6167652f76312f746f702d706f73742d62616467652e7376673f706f73745f69643d31303739323632267468656d653d6c6967687426706572696f643d6461696c7926743d31373731373439313730383638"&gt;&lt;/a&gt;
 &lt;/p&gt;
&lt;br&gt;
&lt;a href="https://discord.gg/sGdnKwB3qq" rel="nofollow noopener noreferrer"&gt;
  &lt;img alt="Discord Community" src="https://camo.githubusercontent.com/b8f979318aaabc8dec512b9d4e6e2a12431fba3c8a3b8738e1a97a0722d4e4bf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446973636f72642d436f6d6d756e6974792d3538363546323f6c6f676f3d646973636f7264266c6162656c436f6c6f723d7768697465"&gt;
&lt;/a&gt; &lt;a href="https://goreportcard.com/report/github.com/HexmosTech/git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="Go Report Card" src="https://camo.githubusercontent.com/e74c0651c3ee9165a2ed01cb0f6842c494029960df30eb9c24cf622d3d21bf46/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f4865786d6f73546563682f6769742d6c7263"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml" rel="noopener noreferrer"&gt;&lt;img alt="gitleaks.yml" title="gitleaks.yml: Secret scanning workflow" src="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml" rel="noopener noreferrer"&gt;&lt;img alt="osv-scanner.yml" title="osv-scanner.yml: Dependency vulnerability scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml" rel="noopener noreferrer"&gt;&lt;img alt="govulncheck.yml" title="govulncheck.yml: Go vulnerability check" src="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml" rel="noopener noreferrer"&gt;&lt;img alt="semgrep.yml" title="semgrep.yml: Static analysis security scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml/badge.svg"&gt;&lt;/a&gt; &lt;a rel="noopener noreferrer" href="https://github.com/HexmosTech/git-lrc/./gfx/dependabot-enabled.svg"&gt;&lt;img alt="dependabot-enabled" title="dependabot-enabled: Automated dependency updates are enabled" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FHexmosTech%2Fgit-lrc%2FHEAD%2F.%2Fgfx%2Fdependabot-enabled.svg"&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;

&lt;p&gt;AI agents write code fast. They also &lt;em&gt;silently remove logic&lt;/em&gt;, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;git-lrc&lt;/code&gt; fixes this.&lt;/strong&gt; It hooks into &lt;code&gt;git commit&lt;/code&gt; and reviews every diff &lt;em&gt;before&lt;/em&gt; it lands. 60-second setup. Completely free.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;See It In Action&lt;/h2&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;See git-lrc catch serious security issues such as leaked credentials, expensive cloud
operations, and sensitive material in log statements&lt;/p&gt;
&lt;/blockquote&gt;

  
    
    

    &lt;span class="m-1"&gt;git-lrc-intro-60s.mp4&lt;/span&gt;
    
  

  

  


&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Why&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;🤖 &lt;strong&gt;AI agents silently break things.&lt;/strong&gt; Code removed. Logic changed. Edge cases gone. You won't notice until production.&lt;/li&gt;
&lt;li&gt;🔍 &lt;strong&gt;Catch it before it ships.&lt;/strong&gt; AI-powered inline comments show you &lt;em&gt;exactly&lt;/em&gt; what changed and what looks wrong.&lt;/li&gt;
&lt;li&gt;🔁 &lt;strong&gt;Build a&lt;/strong&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>webdev</category>
      <category>programming</category>
      <category>architecture</category>
      <category>database</category>
    </item>
    <item>
      <title>What's an AI Gateway and do you think you need one?</title>
      <dc:creator>Athreya aka Maneshwar</dc:creator>
      <pubDate>Mon, 13 Apr 2026 15:52:46 +0000</pubDate>
      <link>https://forem.com/lovestaco/whats-an-ai-gateway-and-do-you-think-you-need-one-39c1</link>
      <guid>https://forem.com/lovestaco/whats-an-ai-gateway-and-do-you-think-you-need-one-39c1</guid>
      <description>&lt;p&gt;It usually starts simple.&lt;/p&gt;

&lt;p&gt;You're building a feature in  your team with an AI feature in the product.&lt;/p&gt;

&lt;p&gt;One API call to OpenAI. Maybe wrapped in a small helper function. You ship a feature. It works. Then things start creeping in.&lt;/p&gt;

&lt;p&gt;Another team wants to use it. Someone adds a second model. Now you’ve got API keys sitting in different repos. &lt;/p&gt;

&lt;p&gt;Nobody’s really tracking usage. Finance asks how much you're spending on AI this month, you don’t have a clear answer which team is using how much. &lt;/p&gt;

&lt;p&gt;Then security shows up asking where prompts and responses are going what are the guardrails list and share it with us.&lt;/p&gt;

&lt;p&gt;And at some point, a provider slows down or goes down, and suddenly your app is stuck waiting on a single dependency you don’t control.&lt;/p&gt;

&lt;p&gt;Now you’ve got:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiple teams calling different models&lt;/li&gt;
&lt;li&gt;No centralized control&lt;/li&gt;
&lt;li&gt;No clear cost visibility&lt;/li&gt;
&lt;li&gt;Zero guardrails&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is usually the moment people start searching:&lt;br&gt;
&lt;strong&gt;“Do I actually need an AI gateway?”&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What an AI Gateway Actually Is (Without the Buzzwords)
&lt;/h2&gt;

&lt;p&gt;If you’ve worked with backend systems, you already know how an API Gateway works.&lt;/p&gt;

&lt;p&gt;It sits in front of your services and handles things like routing, authentication, rate limiting, and observability,  so your services don’t have to deal with that themselves.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8m7uq8hrsm7fqx84loen.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8m7uq8hrsm7fqx84loen.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An &lt;a href="https://www.ibm.com/think/topics/ai-gateway" rel="noopener noreferrer"&gt;AI Gateway&lt;/a&gt; works in a very similar way.&lt;/p&gt;

&lt;p&gt;But instead of sitting in front of microservices, it sits in front of your model providers.&lt;/p&gt;

&lt;p&gt;At its core, an AI Gateway is just a layer between your application and the LLM APIs you’re calling.&lt;/p&gt;

&lt;p&gt;Instead of your app directly hitting providers like OpenAI or Anthropic, every request goes through this gateway first.&lt;/p&gt;

&lt;p&gt;That one change unlocks a lot.&lt;/p&gt;

&lt;p&gt;Now you have a single place that can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Route requests across different models&lt;/li&gt;
&lt;li&gt;Handle authentication centrally&lt;/li&gt;
&lt;li&gt;Enforce rate limits&lt;/li&gt;
&lt;li&gt;Track usage and cost at a detailed level (tokens, not just requests)&lt;/li&gt;
&lt;li&gt;Apply guardrails on inputs and outputs&lt;/li&gt;
&lt;li&gt;Give you visibility into what’s actually happening&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most teams don’t start here though.&lt;/p&gt;

&lt;p&gt;They usually go through this progression:&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;1. Raw SDKs&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;You use something like the OpenAI SDK. Quick to set up, works great, as long as it’s just one team and one use case.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;2. Simple proxies (like &lt;a href="https://www.litellm.ai/" rel="noopener noreferrer"&gt;LiteLLM&lt;/a&gt;)&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;You add a thin layer to route between models. Helps a bit, but governance, security, and cost tracking are still pretty limited.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;3. AI Gateway&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;This is where things become structured. Instead of every team doing their own thing, you now have a centralized control plane managing how AI is used across your org.&lt;/p&gt;

&lt;p&gt;The key difference isn’t just routing, it’s understanding.&lt;/p&gt;

&lt;p&gt;An API Gateway can tell you:&lt;br&gt;
“this service got 10,000 requests.”&lt;/p&gt;

&lt;p&gt;An AI Gateway can tell you:&lt;br&gt;
“this team used 4M tokens on GPT-4, spent $X, and triggered guardrails 3 times.”&lt;/p&gt;

&lt;p&gt;Without it, your AI usage grows organically (read: chaotically).&lt;br&gt;
With it, you can actually manage it.&lt;/p&gt;

&lt;h2&gt;
  
  
  So… do you actually need one?
&lt;/h2&gt;

&lt;p&gt;This is the part most people overcomplicate.&lt;/p&gt;

&lt;p&gt;You don’t need a framework. You don’t need a 10-step checklist.&lt;/p&gt;

&lt;p&gt;You just need to be honest about how your setup actually looks today, not how you &lt;em&gt;think&lt;/em&gt; it looks.&lt;/p&gt;

&lt;h3&gt;
  
  
  You probably don’t need one (yet)
&lt;/h3&gt;

&lt;p&gt;If your world is still pretty contained, you’re fine.&lt;/p&gt;

&lt;p&gt;One team building one feature, calling one model, with a bill that’s small enough that nobody’s asking questions, this kind of setup doesn’t need extra infrastructure yet. &lt;/p&gt;

&lt;p&gt;Seriously.&lt;/p&gt;

&lt;p&gt;Adding an AI Gateway here is like adding Kubernetes to a side project.&lt;br&gt;
You &lt;em&gt;can&lt;/em&gt; do it. You probably shouldn’t.&lt;/p&gt;

&lt;p&gt;Just ship.&lt;/p&gt;

&lt;h3&gt;
  
  
  You &lt;em&gt;do&lt;/em&gt; need one (or you’re about to)
&lt;/h3&gt;

&lt;p&gt;Now flip it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;multiple teams are using LLMs independently&lt;/li&gt;
&lt;li&gt;you’re juggling OpenAI + Anthropic (or thinking about it)&lt;/li&gt;
&lt;li&gt;someone from compliance said words like “HIPAA”, “GDPR”, “SOC 2”, blah, blah, blah...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7daf5xajvdc4zth09sdg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7daf5xajvdc4zth09sdg.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;finance asked for a breakdown and you gave them… vibes&lt;/li&gt;
&lt;li&gt;you’ve had that one moment where you thought:
“wait… did we just send something sensitive to an LLM?”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And then there’s that subtle moment where you realize something could go wrong.&lt;/p&gt;

&lt;p&gt;Maybe you don’t know exactly what’s being sent in prompts. Maybe logs are incomplete. Maybe you’re not sure how to stop a bad request before it reaches the model.&lt;/p&gt;

&lt;p&gt;That’s usually the signal.&lt;/p&gt;

&lt;p&gt;You don’t feel like you’re running “complex infrastructure,” but the problems you’re dealing with are already infrastructure problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a production AI setup actually looks like
&lt;/h2&gt;

&lt;p&gt;This is where things stop being “a few API calls” and start looking like a system.&lt;/p&gt;

&lt;p&gt;Recently, I came across TrueFoundry while digging into how teams handle this at scale, and it’s a pretty good example of what this setup looks like in practice.&lt;/p&gt;

&lt;p&gt;Instead of every team managing their own keys and integrations, everything goes through one layer. That one change removes a surprising amount of chaos.&lt;/p&gt;

&lt;p&gt;So now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;there’s a &lt;strong&gt;single API key&lt;/strong&gt; internally
(teams don’t touch provider credentials anymore)&lt;/li&gt;
&lt;li&gt;you can set &lt;strong&gt;budgets and rate limits per team&lt;/strong&gt;
so one experiment doesn’t accidentally burn your entire budget&lt;/li&gt;
&lt;li&gt;if OpenAI slows down, you can &lt;strong&gt;fallback to Anthropic automatically&lt;/strong&gt;
instead of your feature just breaking&lt;/li&gt;
&lt;li&gt;every request is &lt;strong&gt;tracked&lt;/strong&gt;
prompt, response, tokens, cost — all of it&lt;/li&gt;
&lt;li&gt;you can add &lt;strong&gt;guardrails&lt;/strong&gt;
PII filtering, prompt injection checks, whatever your security team keeps asking about&lt;/li&gt;
&lt;li&gt;and the whole thing can run in your &lt;strong&gt;own VPC / on-prem&lt;/strong&gt;
so data isn’t flying around random third-party infra&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Performance wise, this isn’t some heavy layer either.&lt;/p&gt;

&lt;p&gt;We’re talking about handling 350+ requests per second on a single vCPU with sub-3ms latency, which means it adds control without slowing things down in any meaningful way.&lt;/p&gt;

&lt;p&gt;Also worth noting, this space is becoming real infra, not just hacks.&lt;/p&gt;

&lt;p&gt;Tools like this are already showing up in places like the &lt;a href="https://www.gartner.com/en/documents/7051698" rel="noopener noreferrer"&gt;Gartner Market Guide for AI Gateways&lt;/a&gt;, which is usually a signal that “okay, this is a category now”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb6wc1frp3j29a6u9j7s4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb6wc1frp3j29a6u9j7s4.png" alt=" " width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The boring but real conclusion
&lt;/h2&gt;

&lt;p&gt;Most teams don’t wake up and say:&lt;/p&gt;

&lt;p&gt;“today we implement an AI Gateway”&lt;/p&gt;

&lt;p&gt;They get pushed into it by problems.&lt;/p&gt;

&lt;p&gt;If you read the earlier section and thought:&lt;/p&gt;

&lt;p&gt;“yeah… we’re kinda there already”&lt;/p&gt;

&lt;p&gt;Then you probably are.&lt;/p&gt;

&lt;p&gt;And the tradeoff is simple:&lt;br&gt;
You either spend a bit of time setting up structure now, or you keep paying for it later in the form of confusion, rising costs, and occasional fire drills that nobody enjoys dealing with.&lt;/p&gt;

&lt;p&gt;Pick your pain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it (if you’re already feeling the pain)
&lt;/h2&gt;

&lt;p&gt;At this point, you can keep patching things together… or just try something like &lt;a href="https://www.truefoundry.com/?ref=dev.to"&gt;TrueFoundry&lt;/a&gt; and see what a structured setup actually feels like.&lt;/p&gt;

&lt;p&gt;You can get it running in your own cloud pretty quickly, without needing a long setup process or even a credit card.&lt;/p&gt;

&lt;p&gt;Even if you decide not to stick with it, going through the process once will give you a much clearer picture of what’s missing in your current setup.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcytr8655q6xavu7t2kot.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcytr8655q6xavu7t2kot.png" alt=" " width="600" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>AUTOINCREMENT in SQLite</title>
      <dc:creator>Athreya aka Maneshwar</dc:creator>
      <pubDate>Sun, 12 Apr 2026 17:45:35 +0000</pubDate>
      <link>https://forem.com/lovestaco/autoincrement-in-sqlite-5642</link>
      <guid>https://forem.com/lovestaco/autoincrement-in-sqlite-5642</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Maneshwar. I'm building git-lrc, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/em&gt;&lt;/p&gt; 

&lt;p&gt;When working with SQLite, generating unique IDs is something you deal with almost immediately. &lt;/p&gt;

&lt;p&gt;Most developers assume that &lt;code&gt;AUTOINCREMENT&lt;/code&gt; is required for this, but SQLite already handles auto-incrementing behavior by default in a slightly different way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Default Auto-Increment Behavior
&lt;/h2&gt;

&lt;p&gt;If you define a column like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;t1&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="nb"&gt;INTEGER&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;SQLite will automatically assign values to &lt;code&gt;a&lt;/code&gt; whenever you insert &lt;code&gt;NULL&lt;/code&gt; or don’t provide a value at all.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;t1&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In most cases, SQLite assigns a value that is &lt;strong&gt;one greater than the current maximum&lt;/strong&gt; in that column. If the table is empty, it starts from &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This makes it feel like standard auto-increment behavior, and for many applications, this is more than enough.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Subtle Catch
&lt;/h2&gt;

&lt;p&gt;The important detail is that SQLite only guarantees &lt;strong&gt;current uniqueness&lt;/strong&gt;, not historical uniqueness.&lt;/p&gt;

&lt;p&gt;If you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Insert rows → 1, 2, 3&lt;/li&gt;
&lt;li&gt;Delete row with ID 3&lt;/li&gt;
&lt;li&gt;Insert again&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;SQLite &lt;strong&gt;may reuse 3&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This is not a bug. It is simply how SQLite optimizes ID generation. &lt;/p&gt;

&lt;p&gt;It avoids keeping extra state and just looks at existing values.&lt;/p&gt;

&lt;p&gt;For internal systems, this usually doesn’t matter. But if IDs are exposed outside (like APIs or logs), reuse can create confusion.&lt;/p&gt;
&lt;h2&gt;
  
  
  What AUTOINCREMENT Actually Does
&lt;/h2&gt;

&lt;p&gt;When you explicitly use:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;t1&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="nb"&gt;INTEGER&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt; &lt;span class="n"&gt;AUTOINCREMENT&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;SQLite switches to a stricter strategy.&lt;/p&gt;

&lt;p&gt;Now, instead of checking the current max value, it remembers the &lt;strong&gt;largest value ever used&lt;/strong&gt; and always generates a new value greater than that.&lt;/p&gt;

&lt;p&gt;So even if you delete rows, old IDs are never reused.&lt;/p&gt;

&lt;p&gt;This gives you a stronger guarantee:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IDs are unique across the entire lifetime of the table&lt;/li&gt;
&lt;li&gt;No accidental reuse&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  The Role of sqlite_sequence
&lt;/h2&gt;

&lt;p&gt;To make this work, SQLite maintains a special internal table called &lt;code&gt;sqlite_sequence&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It stores:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Table name&lt;/li&gt;
&lt;li&gt;Highest ID ever used&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This table is created automatically when you first insert into a table that uses &lt;code&gt;AUTOINCREMENT&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Each new insert updates this value so SQLite always knows what comes next.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why Not Always Use AUTOINCREMENT?
&lt;/h2&gt;

&lt;p&gt;At first glance, &lt;code&gt;AUTOINCREMENT&lt;/code&gt; seems like the safer option. But it comes with tradeoffs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It adds a small performance overhead&lt;/li&gt;
&lt;li&gt;It requires maintaining extra state (&lt;code&gt;sqlite_sequence&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;It prevents reuse, which may not always be necessary&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also, SQLite has a limit on integer values. If the maximum value is ever reached, further inserts will fail.&lt;/p&gt;

&lt;p&gt;SQLite already gives you auto-incrementing IDs without needing &lt;code&gt;AUTOINCREMENT&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;The keyword is only for stricter guarantees, not basic functionality.&lt;/p&gt;

&lt;p&gt;Instead of blindly adding &lt;code&gt;AUTOINCREMENT&lt;/code&gt;, you choose it only when your system actually needs that level of consistency.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyzvpkxm9mga1pweneahx.png" alt="git-lrc" width="800" height="109"&gt;&lt;/a&gt; &lt;br&gt;
 *AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production. &lt;/p&gt;

&lt;p&gt;git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.* &lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use. &lt;/p&gt;

&lt;p&gt;⭐ Star it on GitHub: &lt;br&gt;
 &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/HexmosTech" rel="noopener noreferrer"&gt;
        HexmosTech
      &lt;/a&gt; / &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;
        git-lrc
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Free, Unlimited AI Code Reviews That Run on Commit
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div&gt;
&lt;p&gt;| &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.da.md" rel="noopener noreferrer"&gt;🇩🇰 Dansk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.es.md" rel="noopener noreferrer"&gt;🇪🇸 Español&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fa.md" rel="noopener noreferrer"&gt;🇮🇷 Farsi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fi.md" rel="noopener noreferrer"&gt;🇫🇮 Suomi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ja.md" rel="noopener noreferrer"&gt;🇯🇵 日本語&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.nn.md" rel="noopener noreferrer"&gt;🇳🇴 Norsk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.pt.md" rel="noopener noreferrer"&gt;🇵🇹 Português&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ru.md" rel="noopener noreferrer"&gt;🇷🇺 Русский&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.sq.md" rel="noopener noreferrer"&gt;🇦🇱 Shqip&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.zh.md" rel="noopener noreferrer"&gt;🇨🇳 中文&lt;/a&gt; |&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;img width="60" alt="git-lrc logo" src="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;/a&gt;
&lt;br&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;git-lrc&lt;/h1&gt;
&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Free, Unlimited AI Code Reviews That Run on Commit&lt;/h2&gt;
&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.producthunt.com/products/git-lrc?embed=true&amp;amp;utm_source=badge-top-post-badge&amp;amp;utm_medium=badge&amp;amp;utm_campaign=badge-git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt" width="200" src="https://camo.githubusercontent.com/87bf2d4283c1e0aa99e254bd17fefb1c67c0c0d39300043a243a4aa633b6cecc/68747470733a2f2f6170692e70726f6475637468756e742e636f6d2f776964676574732f656d6265642d696d6167652f76312f746f702d706f73742d62616467652e7376673f706f73745f69643d31303739323632267468656d653d6c6967687426706572696f643d6461696c7926743d31373731373439313730383638"&gt;&lt;/a&gt;
 &lt;/p&gt;
&lt;br&gt;
&lt;a href="https://discord.gg/sGdnKwB3qq" rel="nofollow noopener noreferrer"&gt;
  &lt;img alt="Discord Community" src="https://camo.githubusercontent.com/b8f979318aaabc8dec512b9d4e6e2a12431fba3c8a3b8738e1a97a0722d4e4bf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446973636f72642d436f6d6d756e6974792d3538363546323f6c6f676f3d646973636f7264266c6162656c436f6c6f723d7768697465"&gt;
&lt;/a&gt; &lt;a href="https://goreportcard.com/report/github.com/HexmosTech/git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="Go Report Card" src="https://camo.githubusercontent.com/e74c0651c3ee9165a2ed01cb0f6842c494029960df30eb9c24cf622d3d21bf46/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f4865786d6f73546563682f6769742d6c7263"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml" rel="noopener noreferrer"&gt;&lt;img alt="gitleaks.yml" title="gitleaks.yml: Secret scanning workflow" src="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml" rel="noopener noreferrer"&gt;&lt;img alt="osv-scanner.yml" title="osv-scanner.yml: Dependency vulnerability scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml" rel="noopener noreferrer"&gt;&lt;img alt="govulncheck.yml" title="govulncheck.yml: Go vulnerability check" src="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml" rel="noopener noreferrer"&gt;&lt;img alt="semgrep.yml" title="semgrep.yml: Static analysis security scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml/badge.svg"&gt;&lt;/a&gt; &lt;a rel="noopener noreferrer" href="https://github.com/HexmosTech/git-lrc/./gfx/dependabot-enabled.svg"&gt;&lt;img alt="dependabot-enabled" title="dependabot-enabled: Automated dependency updates are enabled" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FHexmosTech%2Fgit-lrc%2FHEAD%2F.%2Fgfx%2Fdependabot-enabled.svg"&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;

&lt;p&gt;AI agents write code fast. They also &lt;em&gt;silently remove logic&lt;/em&gt;, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;git-lrc&lt;/code&gt; fixes this.&lt;/strong&gt; It hooks into &lt;code&gt;git commit&lt;/code&gt; and reviews every diff &lt;em&gt;before&lt;/em&gt; it lands. 60-second setup. Completely free.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;See It In Action&lt;/h2&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;See git-lrc catch serious security issues such as leaked credentials, expensive cloud
operations, and sensitive material in log statements&lt;/p&gt;
&lt;/blockquote&gt;

  
    
    

    &lt;span class="m-1"&gt;git-lrc-intro-60s.mp4&lt;/span&gt;
    
  

  

  


&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Why&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;🤖 &lt;strong&gt;AI agents silently break things.&lt;/strong&gt; Code removed. Logic changed. Edge cases gone. You won't notice until production.&lt;/li&gt;
&lt;li&gt;🔍 &lt;strong&gt;Catch it before it ships.&lt;/strong&gt; AI-powered inline comments show you &lt;em&gt;exactly&lt;/em&gt; what changed and what looks wrong.&lt;/li&gt;
&lt;li&gt;🔁 &lt;strong&gt;Build a&lt;/strong&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>webdev</category>
      <category>programming</category>
      <category>architecture</category>
      <category>database</category>
    </item>
    <item>
      <title>Subqueries &amp; Views in SQLite: Writing Smarter, Cleaner Queries</title>
      <dc:creator>Athreya aka Maneshwar</dc:creator>
      <pubDate>Sat, 11 Apr 2026 19:52:43 +0000</pubDate>
      <link>https://forem.com/lovestaco/subqueries-views-in-sqlite-writing-smarter-cleaner-queries-5399</link>
      <guid>https://forem.com/lovestaco/subqueries-views-in-sqlite-writing-smarter-cleaner-queries-5399</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Maneshwar. I'm building git-lrc, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/em&gt;&lt;/p&gt; 

&lt;p&gt;In the previous discussion, we explored how PRAGMA gives you control over SQLite’s internal behavior. &lt;/p&gt;

&lt;p&gt;Now, let’s see how you actually &lt;strong&gt;structure smarter queries&lt;/strong&gt; using &lt;strong&gt;subqueries&lt;/strong&gt; and &lt;strong&gt;views&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;These aren’t just SQL features. &lt;/p&gt;

&lt;p&gt;They’re tools that help you write cleaner logic, reduce duplication, and make your database easier to work with.&lt;/p&gt;

&lt;h2&gt;
  
  
  Subqueries: Queries Inside Queries
&lt;/h2&gt;

&lt;p&gt;At its core, a basic SQL query looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;x&lt;/code&gt; → columns&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;y&lt;/code&gt; → tables&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;z&lt;/code&gt; → condition&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now here’s where things get interesting:&lt;br&gt;
That &lt;code&gt;z&lt;/code&gt; (the condition) can itself contain another query.&lt;/p&gt;

&lt;p&gt;That’s a &lt;strong&gt;subquery&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  A Simple Subquery Example
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; 
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;Students&lt;/span&gt; 
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt; 
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;Admitted_to&lt;/span&gt; 
    &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;doj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Jan 01, 2000'&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;What’s happening here?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inner query → finds student IDs admitted on a specific date&lt;/li&gt;
&lt;li&gt;Outer query → fetches names of those students&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The inner query runs first, then feeds results into the outer query.&lt;/p&gt;
&lt;h3&gt;
  
  
  Where You Can Use Subqueries
&lt;/h3&gt;

&lt;p&gt;Subqueries aren’t limited to &lt;code&gt;WHERE&lt;/code&gt;. You can use them in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;WHERE&lt;/code&gt; clause (most common)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FROM&lt;/code&gt; clause (as derived tables)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;HAVING&lt;/code&gt; clause (with grouped data)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They act like &lt;strong&gt;temporary datasets&lt;/strong&gt; inside your query.&lt;/p&gt;
&lt;h3&gt;
  
  
  Correlated Subqueries: When Things Get Dynamic
&lt;/h3&gt;

&lt;p&gt;Now we step into more advanced territory.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;correlated subquery&lt;/strong&gt; is one that depends on the outer query.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; 
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;Students&lt;/span&gt; 
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; 
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;Admitted_to&lt;/span&gt; 
    &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Students&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sid&lt;/span&gt; 
    &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;doj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Jan 01, 2000'&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  What’s different here?
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The inner query references &lt;code&gt;Students.sid&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;That means it &lt;strong&gt;cannot run independently&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;It depends on each row from the outer query&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  How Correlated Subqueries Actually Execute
&lt;/h3&gt;

&lt;p&gt;This is where many people misunderstand what’s happening.&lt;/p&gt;

&lt;p&gt;For &lt;strong&gt;each row&lt;/strong&gt; in &lt;code&gt;Students&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;SQLite takes that row’s &lt;code&gt;sid&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Substitutes it into the subquery&lt;/li&gt;
&lt;li&gt;Executes the subquery&lt;/li&gt;
&lt;li&gt;Decides whether to include that row&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So instead of running once, the subquery runs &lt;strong&gt;multiple times&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This makes correlated subqueries:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Powerful&lt;/li&gt;
&lt;li&gt;But potentially slower&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  When to Use Subqueries (and When Not To)
&lt;/h3&gt;

&lt;p&gt;Use them when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You want clear, readable logic&lt;/li&gt;
&lt;li&gt;You need intermediate filtering&lt;/li&gt;
&lt;li&gt;You’re avoiding complex joins&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Avoid them when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Performance is critical&lt;/li&gt;
&lt;li&gt;A join can do the same job more efficiently&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Views: Virtual Tables That Simplify Everything
&lt;/h2&gt;

&lt;p&gt;If subqueries are about &lt;em&gt;embedding logic&lt;/em&gt;, views are about &lt;em&gt;reusing it&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;view&lt;/strong&gt; is basically a &lt;strong&gt;saved query&lt;/strong&gt; that behaves like a table.&lt;/p&gt;

&lt;p&gt;But here’s the key detail:&lt;/p&gt;

&lt;p&gt;A view does &lt;strong&gt;not store data&lt;/strong&gt;&lt;br&gt;
 It stores only the query definition&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating a View
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;VIEW&lt;/span&gt; &lt;span class="n"&gt;view1&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; 
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt; 
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;Students&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This doesn’t create a new table.&lt;/p&gt;

&lt;p&gt;Instead, SQLite stores the query definition internally.&lt;/p&gt;
&lt;h3&gt;
  
  
  Using a View
&lt;/h3&gt;

&lt;p&gt;Once created, you can query it like a normal table:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; 
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;view1&lt;/span&gt; 
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1001&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Behind the scenes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SQLite runs the original query&lt;/li&gt;
&lt;li&gt;Then applies your new query on top&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Why Views Exist (And Why You Should Care)
&lt;/h3&gt;

&lt;p&gt;Views solve real problems:&lt;/p&gt;
&lt;h4&gt;
  
  
  1. Simplify Complex Queries
&lt;/h4&gt;

&lt;p&gt;Instead of repeating a long query everywhere:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write it once as a view&lt;/li&gt;
&lt;li&gt;Reuse it everywhere&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  2. Hide Complexity
&lt;/h4&gt;

&lt;p&gt;You can expose only what users need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hide joins&lt;/li&gt;
&lt;li&gt;Hide sensitive columns&lt;/li&gt;
&lt;li&gt;Present clean datasets&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  3. Provide Schema Independence
&lt;/h4&gt;

&lt;p&gt;If your base table changes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your view may still work unchanged&lt;/li&gt;
&lt;li&gt;Applications using the view stay stable&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Temporary Views
&lt;/h3&gt;

&lt;p&gt;SQLite also allows temporary views:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TEMP&lt;/span&gt; &lt;span class="k"&gt;VIEW&lt;/span&gt; &lt;span class="n"&gt;temp_view&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; 
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;Students&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Exists only during the session&lt;/li&gt;
&lt;li&gt;Automatically deleted when connection closes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Useful for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Testing&lt;/li&gt;
&lt;li&gt;Intermediate processing&lt;/li&gt;
&lt;li&gt;Session-based logic&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  The Catch: Views in SQLite Are Read-Only
&lt;/h3&gt;

&lt;p&gt;Unlike some databases, SQLite does &lt;strong&gt;not allow direct updates&lt;/strong&gt; on views.&lt;/p&gt;

&lt;p&gt;So these won’t work:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;view1&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="n"&gt;view1&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="k"&gt;DELETE&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;view1&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If you need updates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You must use &lt;strong&gt;triggers&lt;/strong&gt; on the view&lt;/li&gt;
&lt;li&gt;Those triggers then modify base tables&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyzvpkxm9mga1pweneahx.png" alt="git-lrc" width="800" height="109"&gt;&lt;/a&gt; &lt;br&gt;
 *AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production. &lt;/p&gt;

&lt;p&gt;git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.* &lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use. &lt;/p&gt;

&lt;p&gt;⭐ Star it on GitHub: &lt;br&gt;
 &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/HexmosTech" rel="noopener noreferrer"&gt;
        HexmosTech
      &lt;/a&gt; / &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;
        git-lrc
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Free, Unlimited AI Code Reviews That Run on Commit
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div&gt;
&lt;p&gt;| &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.da.md" rel="noopener noreferrer"&gt;🇩🇰 Dansk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.es.md" rel="noopener noreferrer"&gt;🇪🇸 Español&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fa.md" rel="noopener noreferrer"&gt;🇮🇷 Farsi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fi.md" rel="noopener noreferrer"&gt;🇫🇮 Suomi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ja.md" rel="noopener noreferrer"&gt;🇯🇵 日本語&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.nn.md" rel="noopener noreferrer"&gt;🇳🇴 Norsk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.pt.md" rel="noopener noreferrer"&gt;🇵🇹 Português&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ru.md" rel="noopener noreferrer"&gt;🇷🇺 Русский&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.sq.md" rel="noopener noreferrer"&gt;🇦🇱 Shqip&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.zh.md" rel="noopener noreferrer"&gt;🇨🇳 中文&lt;/a&gt; |&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;img width="60" alt="git-lrc logo" src="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;/a&gt;
&lt;br&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;git-lrc&lt;/h1&gt;
&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Free, Unlimited AI Code Reviews That Run on Commit&lt;/h2&gt;
&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.producthunt.com/products/git-lrc?embed=true&amp;amp;utm_source=badge-top-post-badge&amp;amp;utm_medium=badge&amp;amp;utm_campaign=badge-git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt" width="200" src="https://camo.githubusercontent.com/87bf2d4283c1e0aa99e254bd17fefb1c67c0c0d39300043a243a4aa633b6cecc/68747470733a2f2f6170692e70726f6475637468756e742e636f6d2f776964676574732f656d6265642d696d6167652f76312f746f702d706f73742d62616467652e7376673f706f73745f69643d31303739323632267468656d653d6c6967687426706572696f643d6461696c7926743d31373731373439313730383638"&gt;&lt;/a&gt;
 &lt;/p&gt;
&lt;br&gt;
&lt;a href="https://discord.gg/sGdnKwB3qq" rel="nofollow noopener noreferrer"&gt;
  &lt;img alt="Discord Community" src="https://camo.githubusercontent.com/b8f979318aaabc8dec512b9d4e6e2a12431fba3c8a3b8738e1a97a0722d4e4bf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446973636f72642d436f6d6d756e6974792d3538363546323f6c6f676f3d646973636f7264266c6162656c436f6c6f723d7768697465"&gt;
&lt;/a&gt; &lt;a href="https://goreportcard.com/report/github.com/HexmosTech/git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="Go Report Card" src="https://camo.githubusercontent.com/e74c0651c3ee9165a2ed01cb0f6842c494029960df30eb9c24cf622d3d21bf46/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f4865786d6f73546563682f6769742d6c7263"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml" rel="noopener noreferrer"&gt;&lt;img alt="gitleaks.yml" title="gitleaks.yml: Secret scanning workflow" src="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml" rel="noopener noreferrer"&gt;&lt;img alt="osv-scanner.yml" title="osv-scanner.yml: Dependency vulnerability scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml" rel="noopener noreferrer"&gt;&lt;img alt="govulncheck.yml" title="govulncheck.yml: Go vulnerability check" src="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml" rel="noopener noreferrer"&gt;&lt;img alt="semgrep.yml" title="semgrep.yml: Static analysis security scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml/badge.svg"&gt;&lt;/a&gt; &lt;a rel="noopener noreferrer" href="https://github.com/HexmosTech/git-lrc/./gfx/dependabot-enabled.svg"&gt;&lt;img alt="dependabot-enabled" title="dependabot-enabled: Automated dependency updates are enabled" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FHexmosTech%2Fgit-lrc%2FHEAD%2F.%2Fgfx%2Fdependabot-enabled.svg"&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;

&lt;p&gt;AI agents write code fast. They also &lt;em&gt;silently remove logic&lt;/em&gt;, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;git-lrc&lt;/code&gt; fixes this.&lt;/strong&gt; It hooks into &lt;code&gt;git commit&lt;/code&gt; and reviews every diff &lt;em&gt;before&lt;/em&gt; it lands. 60-second setup. Completely free.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;See It In Action&lt;/h2&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;See git-lrc catch serious security issues such as leaked credentials, expensive cloud
operations, and sensitive material in log statements&lt;/p&gt;
&lt;/blockquote&gt;

  
    
    

    &lt;span class="m-1"&gt;git-lrc-intro-60s.mp4&lt;/span&gt;
    
  

  

  


&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Why&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;🤖 &lt;strong&gt;AI agents silently break things.&lt;/strong&gt; Code removed. Logic changed. Edge cases gone. You won't notice until production.&lt;/li&gt;
&lt;li&gt;🔍 &lt;strong&gt;Catch it before it ships.&lt;/strong&gt; AI-powered inline comments show you &lt;em&gt;exactly&lt;/em&gt; what changed and what looks wrong.&lt;/li&gt;
&lt;li&gt;🔁 &lt;strong&gt;Build a&lt;/strong&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>webdev</category>
      <category>programming</category>
      <category>database</category>
      <category>architecture</category>
    </item>
    <item>
      <title>SQLite PRAGMA: The Underrated Lever That Controls Your DB</title>
      <dc:creator>Athreya aka Maneshwar</dc:creator>
      <pubDate>Fri, 10 Apr 2026 20:15:35 +0000</pubDate>
      <link>https://forem.com/lovestaco/sqlite-pragma-the-underrated-lever-that-controls-your-db-1m35</link>
      <guid>https://forem.com/lovestaco/sqlite-pragma-the-underrated-lever-that-controls-your-db-1m35</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Maneshwar. I'm building git-lrc, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/em&gt;&lt;/p&gt; 

&lt;p&gt;Most developers treat SQLite like a simple file-based database—create tables, run queries, move on. &lt;/p&gt;

&lt;p&gt;But if you stop there, you’re missing one of its most powerful features: &lt;strong&gt;PRAGMA statements&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;PRAGMA is where SQLite stops being “just a database” and starts becoming something you can actually &lt;em&gt;tune, inspect, and control&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;This isn’t just syntax—it’s control over how your database behaves under the hood.&lt;/p&gt;

&lt;h2&gt;
  
  
  What PRAGMA Really Is
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;PRAGMA&lt;/strong&gt; is a special SQLite command that lets you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Peek into internal database metadata (stuff not stored in tables)&lt;/li&gt;
&lt;li&gt;Change how SQLite behaves internally&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It looks like SQL, but it doesn’t behave like typical SQL.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;PRAGMA&lt;/span&gt; &lt;span class="n"&gt;synchronous&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;OFF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;That single line changes how SQLite writes data to disk—trading safety for speed.&lt;/p&gt;
&lt;h2&gt;
  
  
  PRAGMA Doesn’t Always Run When You Think It Does
&lt;/h2&gt;

&lt;p&gt;Unlike normal SQL, some PRAGMAs execute during the &lt;strong&gt;query preparation phase&lt;/strong&gt;, not execution.&lt;/p&gt;

&lt;p&gt;If you're using SQLite through APIs like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;sqlite3_prepare&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sqlite3_step&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some PRAGMAs take effect &lt;em&gt;before&lt;/em&gt; execution even begins.&lt;/p&gt;

&lt;p&gt;So if something feels inconsistent, this might be why.&lt;/p&gt;
&lt;h2&gt;
  
  
  This Is SQLite-Only Territory
&lt;/h2&gt;

&lt;p&gt;PRAGMAs are &lt;strong&gt;not portable&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Switch to PostgreSQL&lt;/li&gt;
&lt;li&gt;Move to MySQL&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your PRAGMA-based logic? Gone.&lt;/p&gt;

&lt;p&gt;So if portability matters, use them carefully and isolate them.&lt;/p&gt;
&lt;h2&gt;
  
  
  How PRAGMA Syntax Works
&lt;/h2&gt;

&lt;p&gt;You’ve got two ways to use it:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;PRAGMA&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;PRAGMA&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;To read a value:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;PRAGMA&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Boolean shortcuts:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ON&lt;/code&gt;, &lt;code&gt;TRUE&lt;/code&gt;, &lt;code&gt;YES&lt;/code&gt; → 1&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;OFF&lt;/code&gt;, &lt;code&gt;FALSE&lt;/code&gt;, &lt;code&gt;NO&lt;/code&gt; → 0&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Case doesn’t matter.&lt;/p&gt;

&lt;p&gt;Even worse:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Invalid values are silently treated as &lt;code&gt;1&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  The 4 Types of PRAGMA You Should Actually Care About
&lt;/h2&gt;

&lt;p&gt;Instead of memorizing everything, think in categories.&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Schema Inspection (Understanding Your Database)
&lt;/h3&gt;

&lt;p&gt;These help you explore structure without guessing.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;PRAGMA&lt;/span&gt; &lt;span class="n"&gt;table_info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;PRAGMA&lt;/span&gt; &lt;span class="n"&gt;index_list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;PRAGMA&lt;/span&gt; &lt;span class="n"&gt;foreign_key_list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Use this when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Debugging relationships&lt;/li&gt;
&lt;li&gt;Reverse engineering a database&lt;/li&gt;
&lt;li&gt;Building migration tools&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  2. Behavior Control (Where the Real Power Is)
&lt;/h3&gt;

&lt;p&gt;This is where performance and behavior tuning happens.&lt;/p&gt;
&lt;h4&gt;
  
  
  Auto Vacuum
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;PRAGMA&lt;/span&gt; &lt;span class="n"&gt;auto_vacuum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;FULL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Controls how SQLite reclaims unused space.&lt;/p&gt;

&lt;p&gt;Options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;NONE&lt;/code&gt; → default, no cleanup&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FULL&lt;/code&gt; → automatic cleanup&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;INCREMENTAL&lt;/code&gt; → manual cleanup&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;⚠️ You must set this &lt;strong&gt;before creating tables&lt;/strong&gt;.&lt;br&gt;
After that, it won’t change and SQLite won’t complain.&lt;/p&gt;
&lt;h4&gt;
  
  
  Cache Size
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;PRAGMA&lt;/span&gt; &lt;span class="n"&gt;cache_size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Controls how much data SQLite keeps in memory&lt;/li&gt;
&lt;li&gt;Faster reads if increased&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It resets when the connection closes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To make it stick:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;PRAGMA&lt;/span&gt; &lt;span class="n"&gt;default_cache_size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Synchronous Mode (Speed vs Safety)
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;PRAGMA&lt;/span&gt; &lt;span class="n"&gt;synchronous&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;OFF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;FULL&lt;/code&gt; → safest, slowest&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;OFF&lt;/code&gt; → fastest, risky&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Turning it off means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster writes&lt;/li&gt;
&lt;li&gt;Higher chance of corruption during crashes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a deliberate tradeoff, not a free optimization.&lt;/p&gt;
&lt;h3&gt;
  
  
  3. Versioning (For Migrations and Tracking)
&lt;/h3&gt;
&lt;h4&gt;
  
  
  User Version (Safe to Use)
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;PRAGMA&lt;/span&gt; &lt;span class="n"&gt;user_version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This is for &lt;em&gt;you&lt;/em&gt;, not SQLite.&lt;/p&gt;

&lt;p&gt;Use it to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Track schema versions&lt;/li&gt;
&lt;li&gt;Manage migrations&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  4. Debugging and Integrity (Your Safety Net)
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Integrity Check
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;PRAGMA&lt;/span&gt; &lt;span class="n"&gt;integrity_check&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This scans the entire database and tells you if something is wrong.&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;"ok"&lt;/code&gt; → everything is fine&lt;/li&gt;
&lt;li&gt;Error string → something is broken&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use this when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You suspect corruption&lt;/li&gt;
&lt;li&gt;After crashes&lt;/li&gt;
&lt;li&gt;Before backups&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Where People Usually Screw This Up
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Misspelling PRAGMAs and assuming they worked&lt;/li&gt;
&lt;li&gt;Using &lt;code&gt;synchronous = OFF&lt;/code&gt; in production without understanding risk&lt;/li&gt;
&lt;li&gt;Trying to change &lt;code&gt;auto_vacuum&lt;/code&gt; after tables exist&lt;/li&gt;
&lt;li&gt;Messing with &lt;code&gt;schema_version&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Relying on PRAGMAs in apps that need to support multiple databases&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Why PRAGMA Actually Matters
&lt;/h2&gt;

&lt;p&gt;If you ignore PRAGMA, you’re basically using SQLite in “default mode” forever.&lt;/p&gt;

&lt;p&gt;That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Default performance&lt;/li&gt;
&lt;li&gt;Default safety&lt;/li&gt;
&lt;li&gt;Default behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But SQLite isn’t just a database—it’s configurable at a very low level.&lt;/p&gt;

&lt;p&gt;PRAGMA is how you access that layer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyzvpkxm9mga1pweneahx.png" alt="git-lrc" width="800" height="109"&gt;&lt;/a&gt; &lt;br&gt;
 *AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production. &lt;/p&gt;

&lt;p&gt;git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.* &lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use. &lt;/p&gt;

&lt;p&gt;⭐ Star it on GitHub: &lt;br&gt;
 &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/HexmosTech" rel="noopener noreferrer"&gt;
        HexmosTech
      &lt;/a&gt; / &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;
        git-lrc
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Free, Unlimited AI Code Reviews That Run on Commit
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div&gt;
&lt;p&gt;| &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.da.md" rel="noopener noreferrer"&gt;🇩🇰 Dansk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.es.md" rel="noopener noreferrer"&gt;🇪🇸 Español&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fa.md" rel="noopener noreferrer"&gt;🇮🇷 Farsi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fi.md" rel="noopener noreferrer"&gt;🇫🇮 Suomi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ja.md" rel="noopener noreferrer"&gt;🇯🇵 日本語&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.nn.md" rel="noopener noreferrer"&gt;🇳🇴 Norsk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.pt.md" rel="noopener noreferrer"&gt;🇵🇹 Português&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ru.md" rel="noopener noreferrer"&gt;🇷🇺 Русский&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.sq.md" rel="noopener noreferrer"&gt;🇦🇱 Shqip&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.zh.md" rel="noopener noreferrer"&gt;🇨🇳 中文&lt;/a&gt; |&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;img width="60" alt="git-lrc logo" src="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;/a&gt;
&lt;br&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;git-lrc&lt;/h1&gt;
&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Free, Unlimited AI Code Reviews That Run on Commit&lt;/h2&gt;
&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.producthunt.com/products/git-lrc?embed=true&amp;amp;utm_source=badge-top-post-badge&amp;amp;utm_medium=badge&amp;amp;utm_campaign=badge-git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt" width="200" src="https://camo.githubusercontent.com/87bf2d4283c1e0aa99e254bd17fefb1c67c0c0d39300043a243a4aa633b6cecc/68747470733a2f2f6170692e70726f6475637468756e742e636f6d2f776964676574732f656d6265642d696d6167652f76312f746f702d706f73742d62616467652e7376673f706f73745f69643d31303739323632267468656d653d6c6967687426706572696f643d6461696c7926743d31373731373439313730383638"&gt;&lt;/a&gt;
 &lt;/p&gt;
&lt;br&gt;
&lt;a href="https://discord.gg/sGdnKwB3qq" rel="nofollow noopener noreferrer"&gt;
  &lt;img alt="Discord Community" src="https://camo.githubusercontent.com/b8f979318aaabc8dec512b9d4e6e2a12431fba3c8a3b8738e1a97a0722d4e4bf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446973636f72642d436f6d6d756e6974792d3538363546323f6c6f676f3d646973636f7264266c6162656c436f6c6f723d7768697465"&gt;
&lt;/a&gt; &lt;a href="https://goreportcard.com/report/github.com/HexmosTech/git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="Go Report Card" src="https://camo.githubusercontent.com/e74c0651c3ee9165a2ed01cb0f6842c494029960df30eb9c24cf622d3d21bf46/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f4865786d6f73546563682f6769742d6c7263"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml" rel="noopener noreferrer"&gt;&lt;img alt="gitleaks.yml" title="gitleaks.yml: Secret scanning workflow" src="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml" rel="noopener noreferrer"&gt;&lt;img alt="osv-scanner.yml" title="osv-scanner.yml: Dependency vulnerability scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml" rel="noopener noreferrer"&gt;&lt;img alt="govulncheck.yml" title="govulncheck.yml: Go vulnerability check" src="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml" rel="noopener noreferrer"&gt;&lt;img alt="semgrep.yml" title="semgrep.yml: Static analysis security scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml/badge.svg"&gt;&lt;/a&gt; &lt;a rel="noopener noreferrer" href="https://github.com/HexmosTech/git-lrc/./gfx/dependabot-enabled.svg"&gt;&lt;img alt="dependabot-enabled" title="dependabot-enabled: Automated dependency updates are enabled" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FHexmosTech%2Fgit-lrc%2FHEAD%2F.%2Fgfx%2Fdependabot-enabled.svg"&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;

&lt;p&gt;AI agents write code fast. They also &lt;em&gt;silently remove logic&lt;/em&gt;, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;git-lrc&lt;/code&gt; fixes this.&lt;/strong&gt; It hooks into &lt;code&gt;git commit&lt;/code&gt; and reviews every diff &lt;em&gt;before&lt;/em&gt; it lands. 60-second setup. Completely free.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;See It In Action&lt;/h2&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;See git-lrc catch serious security issues such as leaked credentials, expensive cloud
operations, and sensitive material in log statements&lt;/p&gt;
&lt;/blockquote&gt;

  
    
    

    &lt;span class="m-1"&gt;git-lrc-intro-60s.mp4&lt;/span&gt;
    
  

  

  


&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Why&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;🤖 &lt;strong&gt;AI agents silently break things.&lt;/strong&gt; Code removed. Logic changed. Edge cases gone. You won't notice until production.&lt;/li&gt;
&lt;li&gt;🔍 &lt;strong&gt;Catch it before it ships.&lt;/strong&gt; AI-powered inline comments show you &lt;em&gt;exactly&lt;/em&gt; what changed and what looks wrong.&lt;/li&gt;
&lt;li&gt;🔁 &lt;strong&gt;Build a&lt;/strong&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>database</category>
      <category>architecture</category>
    </item>
    <item>
      <title>How SQLite Executes Queries Through Its API Lifecycle</title>
      <dc:creator>Athreya aka Maneshwar</dc:creator>
      <pubDate>Fri, 03 Apr 2026 19:50:31 +0000</pubDate>
      <link>https://forem.com/lovestaco/how-sqlite-executes-queries-through-its-api-lifecycle-3438</link>
      <guid>https://forem.com/lovestaco/how-sqlite-executes-queries-through-its-api-lifecycle-3438</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Maneshwar. I'm building git-lrc, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/em&gt;&lt;/p&gt; 

&lt;p&gt;Now that the internal structures and their interconnections are clear, the final piece is understanding how an application actually drives all of this through the SQLite API.&lt;/p&gt;

&lt;p&gt;It starts with a simple call: &lt;code&gt;sqlite3_open&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When this function is invoked successfully, SQLite allocates a &lt;code&gt;sqlite3&lt;/code&gt; object in the application’s memory space. &lt;/p&gt;

&lt;p&gt;At this point, the connection is initialized, but it is still idle, no SQL has been compiled yet, and the &lt;code&gt;pVdbe&lt;/code&gt; list (which holds compiled statements) is empty.&lt;/p&gt;

&lt;h2&gt;
  
  
  From SQL Text to Bytecode
&lt;/h2&gt;

&lt;p&gt;The moment an application prepares a query using &lt;code&gt;sqlite3_prepare&lt;/code&gt;, SQLite translates the SQL text into a compiled representation.&lt;/p&gt;

&lt;p&gt;Internally, this creates a &lt;strong&gt;Vdbe object&lt;/strong&gt;, which is essentially a bytecode program ready to be executed. &lt;/p&gt;

&lt;p&gt;This object is then added to the &lt;code&gt;pVdbe&lt;/code&gt; list inside the &lt;code&gt;sqlite3&lt;/code&gt; connection.&lt;/p&gt;

&lt;p&gt;At this stage:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The query is compiled&lt;/li&gt;
&lt;li&gt;No execution has happened yet&lt;/li&gt;
&lt;li&gt;No cursors are open&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s like having a program loaded but not yet run.&lt;/p&gt;

&lt;h2&gt;
  
  
  Binding and Execution
&lt;/h2&gt;

&lt;p&gt;Before execution, the application can inject values into the query using &lt;code&gt;sqlite3_bind_*&lt;/code&gt; functions. &lt;/p&gt;

&lt;p&gt;These bindings replace placeholders in the prepared statement.&lt;/p&gt;

&lt;p&gt;Execution begins when &lt;code&gt;sqlite3_step&lt;/code&gt; is called.&lt;/p&gt;

&lt;p&gt;This is where everything comes alive:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The VDBE starts interpreting bytecode&lt;/li&gt;
&lt;li&gt;Cursors are created dynamically&lt;/li&gt;
&lt;li&gt;Each cursor connects to a B-tree (table or index)&lt;/li&gt;
&lt;li&gt;Data is read, filtered, or modified&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These cursors exist only for the duration of execution—they are not permanent structures.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cursor Lifecycle
&lt;/h2&gt;

&lt;p&gt;Cursors are tightly scoped to execution.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Created when the VM starts executing&lt;/li&gt;
&lt;li&gt;Used to traverse B/B+ trees&lt;/li&gt;
&lt;li&gt;Destroyed when execution finishes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the application calls &lt;code&gt;sqlite3_reset&lt;/code&gt;, the statement is reset to its initial state, and any active cursors are closed and cleaned up.&lt;/p&gt;

&lt;p&gt;This ensures that each execution starts fresh, without leftover state.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cleaning Up Resources
&lt;/h2&gt;

&lt;p&gt;Once a prepared statement is no longer needed, the application calls &lt;code&gt;sqlite3_finalize&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This step is crucial—it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Destroys the Vdbe object&lt;/li&gt;
&lt;li&gt;Frees all associated resources&lt;/li&gt;
&lt;li&gt;Removes it from the connection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Only after all prepared statements are finalized should the application close the connection using &lt;code&gt;sqlite3_close&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When the connection is closed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;sqlite3&lt;/code&gt; object is destroyed&lt;/li&gt;
&lt;li&gt;All associated handles become invalid&lt;/li&gt;
&lt;li&gt;The session is fully terminated&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Complete Flow in One View
&lt;/h2&gt;

&lt;p&gt;From start to finish, the lifecycle looks like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open connection → &lt;code&gt;sqlite3_open&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Prepare query → &lt;code&gt;sqlite3_prepare&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Bind parameters → &lt;code&gt;sqlite3_bind_*&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Execute → &lt;code&gt;sqlite3_step&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Reset (optional) → &lt;code&gt;sqlite3_reset&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Finalize → &lt;code&gt;sqlite3_finalize&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Close connection → &lt;code&gt;sqlite3_close&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Closing Thoughts
&lt;/h2&gt;

&lt;p&gt;What looks like a handful of API calls from the outside is actually orchestrating a deep chain of internal operations—compilation, cursor management, B-tree traversal, and disk interaction.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;sqlite3&lt;/code&gt; object sits at the center of it all, acting as the control hub that binds together:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prepared statements (Vdbe)&lt;/li&gt;
&lt;li&gt;Execution flow (VM)&lt;/li&gt;
&lt;li&gt;Storage (B-tree + Pager)&lt;/li&gt;
&lt;li&gt;And application interaction&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you see this lifecycle clearly, SQLite stops feeling magical—it becomes predictable, structured, and surprisingly elegant.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyzvpkxm9mga1pweneahx.png" alt="git-lrc" width="800" height="109"&gt;&lt;/a&gt; &lt;br&gt;
 *AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production. &lt;/p&gt;

&lt;p&gt;git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.* &lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use. &lt;/p&gt;

&lt;p&gt;⭐ Star it on GitHub: &lt;br&gt;
 &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/HexmosTech" rel="noopener noreferrer"&gt;
        HexmosTech
      &lt;/a&gt; / &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;
        git-lrc
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Free, Unlimited AI Code Reviews That Run on Commit
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div&gt;
&lt;p&gt;| &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.da.md" rel="noopener noreferrer"&gt;🇩🇰 Dansk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.es.md" rel="noopener noreferrer"&gt;🇪🇸 Español&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fa.md" rel="noopener noreferrer"&gt;🇮🇷 Farsi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fi.md" rel="noopener noreferrer"&gt;🇫🇮 Suomi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ja.md" rel="noopener noreferrer"&gt;🇯🇵 日本語&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.nn.md" rel="noopener noreferrer"&gt;🇳🇴 Norsk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.pt.md" rel="noopener noreferrer"&gt;🇵🇹 Português&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ru.md" rel="noopener noreferrer"&gt;🇷🇺 Русский&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.sq.md" rel="noopener noreferrer"&gt;🇦🇱 Shqip&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.zh.md" rel="noopener noreferrer"&gt;🇨🇳 中文&lt;/a&gt; |&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;img width="60" alt="git-lrc logo" src="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;/a&gt;
&lt;br&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;git-lrc&lt;/h1&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Free, Unlimited AI Code Reviews That Run on Commit&lt;/h2&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;&lt;a href="https://www.producthunt.com/products/git-lrc?embed=true&amp;amp;utm_source=badge-top-post-badge&amp;amp;utm_medium=badge&amp;amp;utm_campaign=badge-git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt" width="200" src="https://camo.githubusercontent.com/87bf2d4283c1e0aa99e254bd17fefb1c67c0c0d39300043a243a4aa633b6cecc/68747470733a2f2f6170692e70726f6475637468756e742e636f6d2f776964676574732f656d6265642d696d6167652f76312f746f702d706f73742d62616467652e7376673f706f73745f69643d31303739323632267468656d653d6c6967687426706572696f643d6461696c7926743d31373731373439313730383638"&gt;&lt;/a&gt;
 &lt;/p&gt;
&lt;br&gt;
&lt;a href="https://discord.gg/sGdnKwB3qq" rel="nofollow noopener noreferrer"&gt;
  &lt;img alt="Discord Community" src="https://camo.githubusercontent.com/b8f979318aaabc8dec512b9d4e6e2a12431fba3c8a3b8738e1a97a0722d4e4bf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446973636f72642d436f6d6d756e6974792d3538363546323f6c6f676f3d646973636f7264266c6162656c436f6c6f723d7768697465"&gt;
&lt;/a&gt; &lt;a href="https://goreportcard.com/report/github.com/HexmosTech/git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="Go Report Card" src="https://camo.githubusercontent.com/e74c0651c3ee9165a2ed01cb0f6842c494029960df30eb9c24cf622d3d21bf46/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f4865786d6f73546563682f6769742d6c7263"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml" rel="noopener noreferrer"&gt;&lt;img alt="gitleaks.yml" title="gitleaks.yml: Secret scanning workflow" src="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml" rel="noopener noreferrer"&gt;&lt;img alt="osv-scanner.yml" title="osv-scanner.yml: Dependency vulnerability scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml" rel="noopener noreferrer"&gt;&lt;img alt="govulncheck.yml" title="govulncheck.yml: Go vulnerability check" src="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml" rel="noopener noreferrer"&gt;&lt;img alt="semgrep.yml" title="semgrep.yml: Static analysis security scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml/badge.svg"&gt;&lt;/a&gt; &lt;a rel="noopener noreferrer" href="https://github.com/HexmosTech/git-lrc/./gfx/dependabot-enabled.svg"&gt;&lt;img alt="dependabot-enabled" title="dependabot-enabled: Automated dependency updates are enabled" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FHexmosTech%2Fgit-lrc%2FHEAD%2F.%2Fgfx%2Fdependabot-enabled.svg"&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;

&lt;p&gt;AI agents write code fast. They also &lt;em&gt;silently remove logic&lt;/em&gt;, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;git-lrc&lt;/code&gt; fixes this.&lt;/strong&gt; It hooks into &lt;code&gt;git commit&lt;/code&gt; and reviews every diff &lt;em&gt;before&lt;/em&gt; it lands. 60-second setup. Completely free.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;See It In Action&lt;/h2&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;See git-lrc catch serious security issues such as leaked credentials, expensive cloud
operations, and sensitive material in log statements&lt;/p&gt;
&lt;/blockquote&gt;

  
    
    

    &lt;span class="m-1"&gt;git-lrc-intro-60s.mp4&lt;/span&gt;
    
  

  

  


&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Why&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;🤖 &lt;strong&gt;AI agents silently break things.&lt;/strong&gt; Code removed. Logic changed. Edge cases gone. You won't notice until production.&lt;/li&gt;
&lt;li&gt;🔍 &lt;strong&gt;Catch it before it ships.&lt;/strong&gt; AI-powered inline comments show you &lt;em&gt;exactly&lt;/em&gt; what changed and what looks wrong.&lt;/li&gt;
&lt;li&gt;🔁 &lt;strong&gt;Build a&lt;/strong&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>webdev</category>
      <category>programming</category>
      <category>database</category>
      <category>architecture</category>
    </item>
    <item>
      <title>How SQLite Internals Connect Into One Unified System</title>
      <dc:creator>Athreya aka Maneshwar</dc:creator>
      <pubDate>Wed, 01 Apr 2026 17:32:36 +0000</pubDate>
      <link>https://forem.com/lovestaco/how-sqlite-internals-connect-into-one-unified-system-e37</link>
      <guid>https://forem.com/lovestaco/how-sqlite-internals-connect-into-one-unified-system-e37</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Maneshwar. I'm building git-lrc, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/em&gt;&lt;/p&gt; 

&lt;p&gt;In the previous section, we explored individual pieces of SQLite’s internal architecture—the &lt;code&gt;sqlite3&lt;/code&gt; structure, schema objects, tables, indexes, and execution engine. &lt;/p&gt;

&lt;p&gt;Now, it’s time to zoom out and see how all of these components actually interact in a real system.&lt;/p&gt;

&lt;p&gt;This is where things start to feel less like isolated structures and more like a living system.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Big Picture: Application ↔ SQLite
&lt;/h2&gt;

&lt;p&gt;At the highest level, an application interacts with SQLite through two primary handles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;sqlite3*&lt;/code&gt; → Represents a database connection&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sqlite3_stmt*&lt;/code&gt; → Represents a compiled SQL statement&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every API call, whether it’s preparing a query, executing it, or fetching results—flows through these two interfaces.&lt;/p&gt;

&lt;p&gt;SQLite doesn’t just passively execute queries either. &lt;/p&gt;

&lt;p&gt;It allows applications to register custom callback functions. &lt;/p&gt;

&lt;p&gt;When needed, SQLite invokes these callbacks, enabling logic to run inside the application’s space. &lt;/p&gt;

&lt;p&gt;This is how features like custom functions, collations, or hooks are implemented.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff12ugix56lpfxh2qcdkk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff12ugix56lpfxh2qcdkk.png" alt="Figure 9.4: Integration of control data structures" width="776" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Multiple Connections, Multiple Databases
&lt;/h2&gt;

&lt;p&gt;One subtle but powerful feature of SQLite is that an application is not limited to a single connection.&lt;/p&gt;

&lt;p&gt;An application can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open multiple &lt;code&gt;sqlite3*&lt;/code&gt; connections&lt;/li&gt;
&lt;li&gt;Connect each one to different databases—or even the same database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Within a single connection, multiple databases can coexist:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Main database&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Temporary database&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Attached databases&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of these is represented internally by an entry in the &lt;code&gt;Db&lt;/code&gt; array.&lt;/p&gt;

&lt;p&gt;What’s important here is that each database is not just a logical entity—it has its own underlying storage machinery.&lt;/p&gt;

&lt;h2&gt;
  
  
  B-Tree and Pager: The Storage Backbone
&lt;/h2&gt;

&lt;p&gt;Every database is accessed through a &lt;strong&gt;B-tree (or B+ tree)&lt;/strong&gt; structure. &lt;/p&gt;

&lt;p&gt;This is the core storage engine of SQLite.&lt;/p&gt;

&lt;p&gt;Each database connection uses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A dedicated &lt;strong&gt;Btree object&lt;/strong&gt; → Handles structural access to data&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;Pager object&lt;/strong&gt; → Manages disk-level concerns&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Pager is where things get very real. It is responsible for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tracking database file state&lt;/li&gt;
&lt;li&gt;Managing the journal (for transactions and rollback)&lt;/li&gt;
&lt;li&gt;Handling locks&lt;/li&gt;
&lt;li&gt;Maintaining the page cache&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In shared cache mode, multiple B-tree instances can reuse the same Pager through a shared structure (&lt;code&gt;BtShared&lt;/code&gt;). &lt;/p&gt;

&lt;p&gt;This allows efficient memory usage when multiple connections access the same database file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Transactions: Controlled and Isolated
&lt;/h2&gt;

&lt;p&gt;Even though a connection may have multiple databases attached, SQLite enforces an important rule:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A single &lt;code&gt;sqlite3&lt;/code&gt; connection can have only one active transaction at a time.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;However, that transaction can span multiple databases within the same connection.&lt;/p&gt;

&lt;p&gt;SQLite dynamically starts transactions on individual databases depending on what the SQL statement requires. &lt;/p&gt;

&lt;p&gt;This keeps operations efficient while still ensuring consistency.&lt;/p&gt;

&lt;h2&gt;
  
  
  From SQL to Execution: The Role of &lt;code&gt;sqlite3_stmt&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Every SQL statement you write is compiled into a bytecode program.&lt;/p&gt;

&lt;p&gt;That compiled form is represented by a &lt;code&gt;sqlite3_stmt*&lt;/code&gt;, backed internally by a &lt;strong&gt;VDBE (Virtual Database Engine)&lt;/strong&gt; program.&lt;/p&gt;

&lt;p&gt;When executed:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The VDBE interprets the bytecode&lt;/li&gt;
&lt;li&gt;It opens &lt;strong&gt;cursors&lt;/strong&gt; to access data&lt;/li&gt;
&lt;li&gt;It performs operations like scan, insert, update, or delete&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Cursors: Navigating the Data
&lt;/h2&gt;

&lt;p&gt;Cursors are the bridge between execution and storage.&lt;/p&gt;

&lt;p&gt;Each SQL statement maintains a set of &lt;strong&gt;VdbeCursor&lt;/strong&gt; objects. &lt;/p&gt;

&lt;p&gt;These are runtime constructs used by the VM to interact with data.&lt;/p&gt;

&lt;p&gt;Here’s how they work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;VdbeCursor&lt;/strong&gt; maps to a &lt;strong&gt;BtCursor&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;BtCursor&lt;/strong&gt; operates on a single B-tree (table or index)&lt;/li&gt;
&lt;li&gt;It allows iteration over records&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This design enables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiple cursors on the same table or index&lt;/li&gt;
&lt;li&gt;Independent traversal without interference&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So even within a single query, SQLite can efficiently scan, filter, and join data using multiple cursors simultaneously.&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting the Flow Together
&lt;/h2&gt;

&lt;p&gt;Let’s trace a typical execution flow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The application prepares a query → gets a &lt;code&gt;sqlite3_stmt*&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;SQLite compiles it into VDBE bytecode&lt;/li&gt;
&lt;li&gt;On execution:

&lt;ul&gt;
&lt;li&gt;VDBE opens cursors&lt;/li&gt;
&lt;li&gt;Cursors access B-tree structures&lt;/li&gt;
&lt;li&gt;B-tree interacts with Pager&lt;/li&gt;
&lt;li&gt;Pager reads/writes pages from disk&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Results flow back up to the application&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All of this is coordinated through the &lt;code&gt;sqlite3&lt;/code&gt; connection object.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyzvpkxm9mga1pweneahx.png" alt="git-lrc" width="800" height="109"&gt;&lt;/a&gt; &lt;br&gt;
 *AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production. &lt;/p&gt;

&lt;p&gt;git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.* &lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use. &lt;/p&gt;

&lt;p&gt;⭐ Star it on GitHub: &lt;br&gt;
 &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/HexmosTech" rel="noopener noreferrer"&gt;
        HexmosTech
      &lt;/a&gt; / &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;
        git-lrc
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Free, Unlimited AI Code Reviews That Run on Commit
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div&gt;
&lt;p&gt;| &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.da.md" rel="noopener noreferrer"&gt;🇩🇰 Dansk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.es.md" rel="noopener noreferrer"&gt;🇪🇸 Español&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fa.md" rel="noopener noreferrer"&gt;🇮🇷 Farsi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fi.md" rel="noopener noreferrer"&gt;🇫🇮 Suomi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ja.md" rel="noopener noreferrer"&gt;🇯🇵 日本語&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.nn.md" rel="noopener noreferrer"&gt;🇳🇴 Norsk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.pt.md" rel="noopener noreferrer"&gt;🇵🇹 Português&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ru.md" rel="noopener noreferrer"&gt;🇷🇺 Русский&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.sq.md" rel="noopener noreferrer"&gt;🇦🇱 Shqip&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.zh.md" rel="noopener noreferrer"&gt;🇨🇳 中文&lt;/a&gt; |&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;img width="60" alt="git-lrc logo" src="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;/a&gt;
&lt;br&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;git-lrc&lt;/h1&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Free, Unlimited AI Code Reviews That Run on Commit&lt;/h2&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;&lt;a href="https://www.producthunt.com/products/git-lrc?embed=true&amp;amp;utm_source=badge-top-post-badge&amp;amp;utm_medium=badge&amp;amp;utm_campaign=badge-git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt" width="200" src="https://camo.githubusercontent.com/87bf2d4283c1e0aa99e254bd17fefb1c67c0c0d39300043a243a4aa633b6cecc/68747470733a2f2f6170692e70726f6475637468756e742e636f6d2f776964676574732f656d6265642d696d6167652f76312f746f702d706f73742d62616467652e7376673f706f73745f69643d31303739323632267468656d653d6c6967687426706572696f643d6461696c7926743d31373731373439313730383638"&gt;&lt;/a&gt;
 &lt;/p&gt;
&lt;br&gt;
&lt;a href="https://goreportcard.com/report/github.com/HexmosTech/git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="Go Report Card" src="https://camo.githubusercontent.com/e74c0651c3ee9165a2ed01cb0f6842c494029960df30eb9c24cf622d3d21bf46/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f4865786d6f73546563682f6769742d6c7263"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml" rel="noopener noreferrer"&gt;&lt;img alt="gitleaks.yml" title="gitleaks.yml: Secret scanning workflow" src="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml" rel="noopener noreferrer"&gt;&lt;img alt="osv-scanner.yml" title="osv-scanner.yml: Dependency vulnerability scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml" rel="noopener noreferrer"&gt;&lt;img alt="govulncheck.yml" title="govulncheck.yml: Go vulnerability check" src="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml" rel="noopener noreferrer"&gt;&lt;img alt="semgrep.yml" title="semgrep.yml: Static analysis security scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml/badge.svg"&gt;&lt;/a&gt; &lt;a rel="noopener noreferrer" href="https://github.com/HexmosTech/git-lrc/./gfx/dependabot-enabled.svg"&gt;&lt;img alt="dependabot-enabled" title="dependabot-enabled: Automated dependency updates are enabled" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FHexmosTech%2Fgit-lrc%2FHEAD%2F.%2Fgfx%2Fdependabot-enabled.svg"&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;

&lt;p&gt;AI agents write code fast. They also &lt;em&gt;silently remove logic&lt;/em&gt;, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;git-lrc&lt;/code&gt; fixes this.&lt;/strong&gt; It hooks into &lt;code&gt;git commit&lt;/code&gt; and reviews every diff &lt;em&gt;before&lt;/em&gt; it lands. 60-second setup. Completely free.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;See It In Action&lt;/h2&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;See git-lrc catch serious security issues such as leaked credentials, expensive cloud
operations, and sensitive material in log statements&lt;/p&gt;
&lt;/blockquote&gt;

  
    
    

    &lt;span class="m-1"&gt;git-lrc-intro-60s.mp4&lt;/span&gt;
    
  

  

  


&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Why&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;🤖 &lt;strong&gt;AI agents silently break things.&lt;/strong&gt; Code removed. Logic changed. Edge cases gone. You won't notice until production.&lt;/li&gt;
&lt;li&gt;🔍 &lt;strong&gt;Catch it before it ships.&lt;/strong&gt; AI-powered inline comments show you &lt;em&gt;exactly&lt;/em&gt; what changed and what looks wrong.&lt;/li&gt;
&lt;li&gt;🔁 &lt;strong&gt;Build a&lt;/strong&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>webdev</category>
      <category>programming</category>
      <category>database</category>
      <category>architecture</category>
    </item>
    <item>
      <title>SQLite Interface Handler: Understanding the sqlite3 Core Structure</title>
      <dc:creator>Athreya aka Maneshwar</dc:creator>
      <pubDate>Tue, 31 Mar 2026 18:39:45 +0000</pubDate>
      <link>https://forem.com/lovestaco/sqlite-interface-handler-understanding-the-sqlite3-core-structure-2976</link>
      <guid>https://forem.com/lovestaco/sqlite-interface-handler-understanding-the-sqlite3-core-structure-2976</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Maneshwar. I'm building git-lrc, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/em&gt;&lt;/p&gt; 

&lt;p&gt;In earlier discussions, we explored several internal control data structures in isolation, each serving a specific purpose inside SQLite. &lt;/p&gt;

&lt;p&gt;However, understanding SQLite in fragments can feel like looking at puzzle pieces without seeing the full picture.&lt;/p&gt;

&lt;p&gt;This chapter ties everything together.&lt;/p&gt;

&lt;p&gt;At the center of SQLite’s architecture lies the &lt;code&gt;sqlite3&lt;/code&gt; structure, which acts as the main interface between the application and the database engine. &lt;/p&gt;

&lt;p&gt;By studying this structure and its relationships with other components, you get a complete, end-to-end understanding of how SQLite organizes and manages its internal state.&lt;/p&gt;

&lt;h2&gt;
  
  
  The &lt;code&gt;sqlite3&lt;/code&gt; Structure
&lt;/h2&gt;

&lt;p&gt;Whenever an application calls the &lt;code&gt;sqlite3_open&lt;/code&gt; API, something important happens behind the scenes. &lt;/p&gt;

&lt;p&gt;SQLite initializes a new database connection (also called a session) and prepares access to the database file.&lt;/p&gt;

&lt;p&gt;This process results in the creation of a &lt;code&gt;sqlite3&lt;/code&gt; object, and the application receives a pointer to it.&lt;/p&gt;

&lt;p&gt;That pointer is not just a reference—it represents the entire connection. &lt;/p&gt;

&lt;p&gt;Every subsequent database operation performed by the application goes through this handle, until the connection is closed using &lt;code&gt;sqlite3_close&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It’s important to note that the application should never directly modify the internal fields of this object. &lt;/p&gt;

&lt;p&gt;It is strictly managed by SQLite itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Internal Composition of &lt;code&gt;sqlite3&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;One of the most important members of the &lt;code&gt;sqlite3&lt;/code&gt; structure is &lt;code&gt;aDb&lt;/code&gt;, which is an array of &lt;code&gt;Db&lt;/code&gt; objects.&lt;/p&gt;

&lt;p&gt;Each &lt;code&gt;Db&lt;/code&gt; object represents a database associated with the connection.&lt;/p&gt;

&lt;p&gt;Typically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;aDb[0]&lt;/code&gt; → Main database&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;aDb[1]&lt;/code&gt; → Temporary database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Additional entries appear when databases are attached dynamically during runtime.&lt;/p&gt;

&lt;p&gt;Internally, SQLite does not refer to databases by name. Instead, it uses their index within the &lt;code&gt;aDb&lt;/code&gt; array. This mapping from name to index is resolved during query compilation.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;nDb&lt;/code&gt; variable keeps track of how many databases are currently active in the connection.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fehgkrzzrqy2y8hqotoi7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fehgkrzzrqy2y8hqotoi7.png" alt="Figure 9.1: Components of sqli te3 objects" width="612" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The &lt;code&gt;Db&lt;/code&gt; Structure
&lt;/h2&gt;

&lt;p&gt;Each entry in the &lt;code&gt;aDb&lt;/code&gt; array is a &lt;code&gt;Db&lt;/code&gt; object, and it contains essential metadata about a database.&lt;/p&gt;

&lt;p&gt;Key components include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;zName&lt;/strong&gt; → Name of the database&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;pBt&lt;/strong&gt; → Pointer to the B-tree structure (core storage engine)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;inTrans&lt;/strong&gt; → Current transaction state&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;pSchema&lt;/strong&gt; → Pointer to schema information&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The schema itself is a rich structure containing multiple hash tables and metadata used for query processing and validation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Schema Organization
&lt;/h2&gt;

&lt;p&gt;The schema is where SQLite keeps track of all structural elements of a database.&lt;/p&gt;

&lt;p&gt;Important members include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;schema_cookie&lt;/strong&gt; → Version of the schema&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;cache_size&lt;/strong&gt; → Page cache configuration&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;tblHash&lt;/strong&gt; → All tables and views&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;idxHash&lt;/strong&gt; → All indexes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;trigHash&lt;/strong&gt; → All triggers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;fkeyHash&lt;/strong&gt; → All foreign keys&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;pSeqTab&lt;/strong&gt; → Pointer to the &lt;code&gt;sqlite_sequence&lt;/code&gt; table&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When a database is opened, SQLite parses its schema and populates these hash tables. &lt;/p&gt;

&lt;p&gt;This allows fast lookup and efficient query planning.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table Representation in Memory
&lt;/h2&gt;

&lt;p&gt;Each SQL table is represented internally as a &lt;code&gt;Table&lt;/code&gt; object.&lt;/p&gt;

&lt;p&gt;This object contains an array called &lt;code&gt;aCol&lt;/code&gt;, which holds all column definitions. Each column is described by a &lt;code&gt;Column&lt;/code&gt; object.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpo6nrjise8nan0aze5fn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpo6nrjise8nan0aze5fn.png" alt="Figure 9.2: Components of Table objects" width="713" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Index Representation
&lt;/h2&gt;

&lt;p&gt;Indexes are also represented as structured objects in memory.&lt;/p&gt;

&lt;p&gt;An &lt;code&gt;Index&lt;/code&gt; object contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;aiColumn&lt;/strong&gt; → Array mapping index columns to table columns&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;tnum&lt;/strong&gt; → Page number where the index root resides&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allows SQLite to efficiently locate and traverse indexed data during query execution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ucl40bpsefl6oyj781g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ucl40bpsefl6oyj781g.png" alt="Figure 9.3: Components of Index objects" width="648" height="310"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Runtime State and Execution
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;sqlite3&lt;/code&gt; structure also keeps track of runtime execution details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;lastRowid&lt;/strong&gt; → The most recent row ID generated by an INSERT&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;errCode / pErr&lt;/strong&gt; → Error tracking&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;flags&lt;/strong&gt; → Current runtime state&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;pVdbe&lt;/strong&gt; → Collection of compiled SQL statements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each compiled SQL statement is represented as a VDBE (Virtual Database Engine) program.&lt;/p&gt;

&lt;p&gt;These are essentially bytecode instructions executed by SQLite’s internal engine.&lt;/p&gt;

&lt;p&gt;Applications interact with these compiled statements using &lt;code&gt;sqlite3_stmt&lt;/code&gt; pointers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting It All Together
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;sqlite3&lt;/code&gt; structure is not just a container—it is the central hub that connects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Database files (&lt;code&gt;Db&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Storage engine (&lt;code&gt;B-tree&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Schema metadata&lt;/li&gt;
&lt;li&gt;Tables and indexes&lt;/li&gt;
&lt;li&gt;Query execution engine (VDBE)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every SQL query flows through this structure. &lt;/p&gt;

&lt;p&gt;From parsing and compilation to execution and result retrieval, everything is orchestrated through &lt;code&gt;sqlite3&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyzvpkxm9mga1pweneahx.png" alt="git-lrc" width="800" height="109"&gt;&lt;/a&gt; &lt;br&gt;
 *AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production. &lt;/p&gt;

&lt;p&gt;git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.* &lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use. &lt;/p&gt;

&lt;p&gt;⭐ Star it on GitHub: &lt;br&gt;
 &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/HexmosTech" rel="noopener noreferrer"&gt;
        HexmosTech
      &lt;/a&gt; / &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;
        git-lrc
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Free, Unlimited AI Code Reviews That Run on Commit
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div&gt;
&lt;p&gt;| &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.da.md" rel="noopener noreferrer"&gt;🇩🇰 Dansk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.es.md" rel="noopener noreferrer"&gt;🇪🇸 Español&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fa.md" rel="noopener noreferrer"&gt;🇮🇷 Farsi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fi.md" rel="noopener noreferrer"&gt;🇫🇮 Suomi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ja.md" rel="noopener noreferrer"&gt;🇯🇵 日本語&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.nn.md" rel="noopener noreferrer"&gt;🇳🇴 Norsk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.pt.md" rel="noopener noreferrer"&gt;🇵🇹 Português&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ru.md" rel="noopener noreferrer"&gt;🇷🇺 Русский&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.sq.md" rel="noopener noreferrer"&gt;🇦🇱 Shqip&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.zh.md" rel="noopener noreferrer"&gt;🇨🇳 中文&lt;/a&gt; |&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;img width="60" alt="git-lrc logo" src="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;/a&gt;
&lt;br&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;git-lrc&lt;/h1&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Free, Unlimited AI Code Reviews That Run on Commit&lt;/h2&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;&lt;a href="https://www.producthunt.com/products/git-lrc?embed=true&amp;amp;utm_source=badge-top-post-badge&amp;amp;utm_medium=badge&amp;amp;utm_campaign=badge-git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt" width="200" src="https://camo.githubusercontent.com/87bf2d4283c1e0aa99e254bd17fefb1c67c0c0d39300043a243a4aa633b6cecc/68747470733a2f2f6170692e70726f6475637468756e742e636f6d2f776964676574732f656d6265642d696d6167652f76312f746f702d706f73742d62616467652e7376673f706f73745f69643d31303739323632267468656d653d6c6967687426706572696f643d6461696c7926743d31373731373439313730383638"&gt;&lt;/a&gt;
 &lt;/p&gt;
&lt;br&gt;
&lt;a href="https://goreportcard.com/report/github.com/HexmosTech/git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="Go Report Card" src="https://camo.githubusercontent.com/e74c0651c3ee9165a2ed01cb0f6842c494029960df30eb9c24cf622d3d21bf46/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f4865786d6f73546563682f6769742d6c7263"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml" rel="noopener noreferrer"&gt;&lt;img alt="gitleaks.yml" title="gitleaks.yml: Secret scanning workflow" src="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml" rel="noopener noreferrer"&gt;&lt;img alt="osv-scanner.yml" title="osv-scanner.yml: Dependency vulnerability scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml" rel="noopener noreferrer"&gt;&lt;img alt="govulncheck.yml" title="govulncheck.yml: Go vulnerability check" src="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml" rel="noopener noreferrer"&gt;&lt;img alt="semgrep.yml" title="semgrep.yml: Static analysis security scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml/badge.svg"&gt;&lt;/a&gt; &lt;a rel="noopener noreferrer" href="https://github.com/HexmosTech/git-lrc/./gfx/dependabot-enabled.svg"&gt;&lt;img alt="dependabot-enabled" title="dependabot-enabled: Automated dependency updates are enabled" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FHexmosTech%2Fgit-lrc%2FHEAD%2F.%2Fgfx%2Fdependabot-enabled.svg"&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;

&lt;p&gt;AI agents write code fast. They also &lt;em&gt;silently remove logic&lt;/em&gt;, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;git-lrc&lt;/code&gt; fixes this.&lt;/strong&gt; It hooks into &lt;code&gt;git commit&lt;/code&gt; and reviews every diff &lt;em&gt;before&lt;/em&gt; it lands. 60-second setup. Completely free.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;See It In Action&lt;/h2&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;See git-lrc catch serious security issues such as leaked credentials, expensive cloud
operations, and sensitive material in log statements&lt;/p&gt;
&lt;/blockquote&gt;

  
    
    

    &lt;span class="m-1"&gt;git-lrc-intro-60s.mp4&lt;/span&gt;
    
  

  

  


&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Why&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;🤖 &lt;strong&gt;AI agents silently break things.&lt;/strong&gt; Code removed. Logic changed. Edge cases gone. You won't notice until production.&lt;/li&gt;
&lt;li&gt;🔍 &lt;strong&gt;Catch it before it ships.&lt;/strong&gt; AI-powered inline comments show you &lt;em&gt;exactly&lt;/em&gt; what changed and what looks wrong.&lt;/li&gt;
&lt;li&gt;🔁 &lt;strong&gt;Build a&lt;/strong&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>database</category>
      <category>webdev</category>
      <category>programming</category>
      <category>architecture</category>
    </item>
    <item>
      <title>From Queries to Bytecode: The Final Pieces of SQLite’s Frontend</title>
      <dc:creator>Athreya aka Maneshwar</dc:creator>
      <pubDate>Sat, 28 Mar 2026 17:50:23 +0000</pubDate>
      <link>https://forem.com/lovestaco/from-queries-to-bytecode-the-final-pieces-of-sqlites-frontend-2ejm</link>
      <guid>https://forem.com/lovestaco/from-queries-to-bytecode-the-final-pieces-of-sqlites-frontend-2ejm</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Maneshwar. I'm building git-lrc, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/em&gt;&lt;/p&gt; 

&lt;p&gt;In the previous part, you saw how SQLite selects indexes and balances filtering with sorting. &lt;/p&gt;

&lt;p&gt;Now we move into another important category of queries.&lt;/p&gt;

&lt;p&gt;Aggregation and subqueries.&lt;/p&gt;

&lt;p&gt;These introduce new challenges because SQLite is no longer just filtering rows. &lt;/p&gt;

&lt;p&gt;It is grouping, transforming, and sometimes restructuring queries entirely.&lt;/p&gt;

&lt;h2&gt;
  
  
  How SQLite Executes GROUP BY
&lt;/h2&gt;

&lt;p&gt;When you use a GROUP BY clause, SQLite introduces a special internal structure called an &lt;strong&gt;aggregator&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This is essentially a temporary table that stores:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;key&lt;/strong&gt; → formed by GROUP BY columns&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;value&lt;/strong&gt; → aggregate data like COUNT, SUM, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;department&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;COUNT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt; &lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;department&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;SQLite processes this in two phases.&lt;/p&gt;

&lt;p&gt;First, it scans rows and builds groups.&lt;/p&gt;

&lt;p&gt;Then, it produces the final results.&lt;/p&gt;

&lt;p&gt;The execution pattern looks like this:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;where-begin  
    compute group-by key  
    focus on the group-by key  
    update aggregate terms  
where-end  
foreach group-by  
    compute result-set  
    send result to caller  
end-foreach
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;During the first phase, SQLite keeps updating aggregate values for each group.&lt;/p&gt;

&lt;p&gt;During the second phase, it outputs the final computed results for each group &lt;/p&gt;

&lt;p&gt;This approach ensures that rows are grouped efficiently without repeatedly scanning the same data.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Problem with Subqueries in FROM
&lt;/h2&gt;

&lt;p&gt;Now consider queries that use subqueries inside the FROM clause.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;t1&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The default way to execute this is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run the inner query&lt;/li&gt;
&lt;li&gt;Store results in a temporary table&lt;/li&gt;
&lt;li&gt;Run the outer query on that table&lt;/li&gt;
&lt;li&gt;Delete the temporary table&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This approach has a major drawback.&lt;/p&gt;

&lt;p&gt;The temporary table has &lt;strong&gt;no indexes&lt;/strong&gt;, so any filtering or joining done by the outer query becomes inefficient. &lt;/p&gt;

&lt;p&gt;It also requires scanning data multiple times.&lt;/p&gt;
&lt;h2&gt;
  
  
  Subquery Flattening: A Smarter Approach
&lt;/h2&gt;

&lt;p&gt;To avoid this overhead, SQLite uses an optimization called &lt;strong&gt;subquery flattening&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead of executing the subquery separately, SQLite merges it into the outer query.&lt;/p&gt;

&lt;p&gt;The previous example becomes:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;t1&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now the query can be executed in a single pass over the table.&lt;/p&gt;

&lt;p&gt;This has two major benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Eliminates temporary tables&lt;/li&gt;
&lt;li&gt;Allows indexes on the base table to be used&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This significantly improves performance &lt;/p&gt;
&lt;h2&gt;
  
  
  When Flattening Is Allowed
&lt;/h2&gt;

&lt;p&gt;Flattening is not always possible.&lt;/p&gt;

&lt;p&gt;SQLite applies this optimization only when a strict set of conditions is satisfied.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The subquery and the outer query do not both use aggregates.
&lt;/li&gt;
&lt;li&gt;The subquery is not an aggregate or the outer query is not a join.
&lt;/li&gt;
&lt;li&gt;The subquery is not the right operand of a left outer join.
&lt;/li&gt;
&lt;li&gt;The subquery is not DISTINCT or the outer query is not a join.
&lt;/li&gt;
&lt;li&gt;The subquery is not DISTINCT or the outer query does not use aggregates.&lt;/li&gt;
&lt;li&gt;The subquery does not use aggregates or the outer query is not DISTINCT.&lt;/li&gt;
&lt;li&gt;The subquery has a FROM clause.
&lt;/li&gt;
&lt;li&gt;The subquery does not use LIMIT or the outer query is not a join.
&lt;/li&gt;
&lt;li&gt;The subquery does not use LIMIT or the outer query does not use aggregates.
&lt;/li&gt;
&lt;li&gt;The subquery does not use aggregates or the outer query does not use LIMIT.
&lt;/li&gt;
&lt;li&gt;The subquery and the outer query do not both have ORDER BY clauses.
&lt;/li&gt;
&lt;li&gt;The subquery and outer query do not both use LIMIT.
&lt;/li&gt;
&lt;li&gt;The subquery does not use OFFSET.&lt;/li&gt;
&lt;li&gt;The outer query is not part of a compound select or the subquery does not have both an  ORDER BY and a LIMIT clause&lt;/li&gt;
&lt;li&gt;The outer query is not an aggregate or the subquery does not contain ORDER BY&lt;/li&gt;
&lt;li&gt;The sub-query is not a compound select, or it is a UNION ALL compound clause made up  entirely of non-aggregate queries, and the parent query:
• is not itself part of a compound select,
• is not an aggregate or DISTINCT query, and
• has no other tables or sub-selects in the FROM clause.  The parent and sub-query may contain WHERE clauses. 
Subject to rules (11), (12) and (13),  they may also contain ORDER BY, LIMIT and OFFSET clauses.&lt;/li&gt;
&lt;li&gt;If the sub-query is a compound select, then all terms of the ORDER by clause of the parent  must be simple references to columns of the sub-query.&lt;/li&gt;
&lt;li&gt;The subquery does not use LIMIT or the outer query does not have a WHERE clause&lt;/li&gt;
&lt;li&gt;If the sub-query is a compound select, then it must not use an ORDER BY clause.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Query flattening is an important optimization when views are used because each use of a view  is translated into a su bquery.&lt;/p&gt;
&lt;h2&gt;
  
  
  Fast MIN and MAX Queries
&lt;/h2&gt;

&lt;p&gt;Aggregation is not always expensive.&lt;/p&gt;

&lt;p&gt;SQLite has a very efficient optimization for queries like:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;MIN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;MAX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If there is no index on the column, SQLite must scan the entire table.&lt;/p&gt;

&lt;p&gt;But if an index exists, SQLite can do something much faster.&lt;/p&gt;

&lt;p&gt;It directly navigates to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;first entry&lt;/strong&gt; in the index for MIN&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;last entry&lt;/strong&gt; in the index for MAX&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since indexes are stored as B-trees, this operation takes &lt;strong&gt;logarithmic time&lt;/strong&gt;, not linear time.&lt;/p&gt;

&lt;p&gt;If the column is an INTEGER PRIMARY KEY, SQLite can even use the table’s primary B+ tree directly.&lt;/p&gt;

&lt;p&gt;This makes MIN and MAX queries extremely efficient when proper indexing is in place &lt;/p&gt;
&lt;h2&gt;
  
  
  Bringing It All Together
&lt;/h2&gt;

&lt;p&gt;At this point, you have seen how SQLite handles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Filtering using WHERE&lt;/li&gt;
&lt;li&gt;Choosing indexes&lt;/li&gt;
&lt;li&gt;Ordering joins&lt;/li&gt;
&lt;li&gt;Grouping results&lt;/li&gt;
&lt;li&gt;Flattening subqueries&lt;/li&gt;
&lt;li&gt;Optimizing aggregations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of this happens before execution, inside the frontend.&lt;/p&gt;

&lt;p&gt;By the time the Virtual Machine runs, everything has already been carefully planned and optimized.&lt;/p&gt;
&lt;h2&gt;
  
  
  Final Thoughts on the Frontend
&lt;/h2&gt;

&lt;p&gt;The SQLite frontend is a complete pipeline:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The tokenizer breaks SQL into tokens&lt;/li&gt;
&lt;li&gt;The parser builds structured representations&lt;/li&gt;
&lt;li&gt;The optimizer reshapes queries for efficiency&lt;/li&gt;
&lt;li&gt;The code generator produces executable bytecode&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of this work is triggered by a single function call:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;sqlite3_prepare&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Query optimization remains one of the most complex and delicate parts of any database system. &lt;/p&gt;

&lt;p&gt;SQLite keeps things relatively simple by using heuristics instead of heavy statistical models, but still manages to achieve strong performance in most real-world scenarios &lt;/p&gt;
&lt;h2&gt;
  
  
  What’s Next
&lt;/h2&gt;

&lt;p&gt;We have now covered the entire frontend pipeline of SQLite, from raw SQL to optimized bytecode.&lt;/p&gt;

&lt;p&gt;In the next series, we will move beyond compilation and explore how SQLite interacts with the outside world.&lt;/p&gt;

&lt;p&gt;We will start with the &lt;strong&gt;SQLite Interface Handler&lt;/strong&gt;, where queries enter the system and results are returned.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyzvpkxm9mga1pweneahx.png" alt="git-lrc" width="800" height="109"&gt;&lt;/a&gt; &lt;br&gt;
 *AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production. &lt;/p&gt;

&lt;p&gt;git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.* &lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use. &lt;/p&gt;

&lt;p&gt;⭐ Star it on GitHub: &lt;br&gt;
 &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/HexmosTech" rel="noopener noreferrer"&gt;
        HexmosTech
      &lt;/a&gt; / &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;
        git-lrc
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Free, Unlimited AI Code Reviews That Run on Commit
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div&gt;
&lt;p&gt;| &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.da.md" rel="noopener noreferrer"&gt;🇩🇰 Dansk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.es.md" rel="noopener noreferrer"&gt;🇪🇸 Español&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fa.md" rel="noopener noreferrer"&gt;🇮🇷 Farsi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fi.md" rel="noopener noreferrer"&gt;🇫🇮 Suomi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ja.md" rel="noopener noreferrer"&gt;🇯🇵 日本語&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.nn.md" rel="noopener noreferrer"&gt;🇳🇴 Norsk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.pt.md" rel="noopener noreferrer"&gt;🇵🇹 Português&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ru.md" rel="noopener noreferrer"&gt;🇷🇺 Русский&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.sq.md" rel="noopener noreferrer"&gt;🇦🇱 Shqip&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.zh.md" rel="noopener noreferrer"&gt;🇨🇳 中文&lt;/a&gt; |&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;img width="60" alt="git-lrc logo" src="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;/a&gt;
&lt;br&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;git-lrc&lt;/h1&gt;
&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Free, Unlimited AI Code Reviews That Run on Commit&lt;/h2&gt;
&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.producthunt.com/products/git-lrc?embed=true&amp;amp;utm_source=badge-top-post-badge&amp;amp;utm_medium=badge&amp;amp;utm_campaign=badge-git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt" width="200" src="https://camo.githubusercontent.com/87bf2d4283c1e0aa99e254bd17fefb1c67c0c0d39300043a243a4aa633b6cecc/68747470733a2f2f6170692e70726f6475637468756e742e636f6d2f776964676574732f656d6265642d696d6167652f76312f746f702d706f73742d62616467652e7376673f706f73745f69643d31303739323632267468656d653d6c6967687426706572696f643d6461696c7926743d31373731373439313730383638"&gt;&lt;/a&gt;
 &lt;/p&gt;
&lt;br&gt;
&lt;a href="https://goreportcard.com/report/github.com/HexmosTech/git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="Go Report Card" src="https://camo.githubusercontent.com/e74c0651c3ee9165a2ed01cb0f6842c494029960df30eb9c24cf622d3d21bf46/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f4865786d6f73546563682f6769742d6c7263"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml" rel="noopener noreferrer"&gt;&lt;img alt="gitleaks.yml" title="gitleaks.yml: Secret scanning workflow" src="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml" rel="noopener noreferrer"&gt;&lt;img alt="osv-scanner.yml" title="osv-scanner.yml: Dependency vulnerability scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml" rel="noopener noreferrer"&gt;&lt;img alt="govulncheck.yml" title="govulncheck.yml: Go vulnerability check" src="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml" rel="noopener noreferrer"&gt;&lt;img alt="semgrep.yml" title="semgrep.yml: Static analysis security scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml/badge.svg"&gt;&lt;/a&gt; &lt;a rel="noopener noreferrer" href="https://github.com/HexmosTech/git-lrc/./gfx/dependabot-enabled.svg"&gt;&lt;img alt="dependabot-enabled" title="dependabot-enabled: Automated dependency updates are enabled" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FHexmosTech%2Fgit-lrc%2F.%2Fgfx%2Fdependabot-enabled.svg"&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;

&lt;p&gt;AI agents write code fast. They also &lt;em&gt;silently remove logic&lt;/em&gt;, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;git-lrc&lt;/code&gt; fixes this.&lt;/strong&gt; It hooks into &lt;code&gt;git commit&lt;/code&gt; and reviews every diff &lt;em&gt;before&lt;/em&gt; it lands. 60-second setup. Completely free.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;See It In Action&lt;/h2&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;See git-lrc catch serious security issues such as leaked credentials, expensive cloud
operations, and sensitive material in log statements&lt;/p&gt;
&lt;/blockquote&gt;

  
    
    

    &lt;span class="m-1"&gt;git-lrc-intro-60s.mp4&lt;/span&gt;
    
  

  

  


&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Why&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;🤖 &lt;strong&gt;AI agents silently break things.&lt;/strong&gt; Code removed. Logic changed. Edge cases gone. You won't notice until production.&lt;/li&gt;
&lt;li&gt;🔍 &lt;strong&gt;Catch it before it ships.&lt;/strong&gt; AI-powered inline comments show you &lt;em&gt;exactly&lt;/em&gt; what changed and what looks wrong.&lt;/li&gt;
&lt;li&gt;🔁 &lt;strong&gt;Build a&lt;/strong&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>webdev</category>
      <category>programming</category>
      <category>database</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Which index should SQLite use?</title>
      <dc:creator>Athreya aka Maneshwar</dc:creator>
      <pubDate>Fri, 27 Mar 2026 19:12:01 +0000</pubDate>
      <link>https://forem.com/lovestaco/which-index-should-sqlite-use-43jl</link>
      <guid>https://forem.com/lovestaco/which-index-should-sqlite-use-43jl</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Maneshwar. I'm building git-lrc, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/em&gt;&lt;/p&gt; 

&lt;p&gt;Even when indexes exist, choosing the wrong one can slow down a query significantly. &lt;/p&gt;

&lt;p&gt;The optimizer’s job here is not just to use an index, but to use the &lt;strong&gt;right index&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  One Table, One Index (Mostly)
&lt;/h2&gt;

&lt;p&gt;For each table in a query, SQLite can typically use &lt;strong&gt;only one index&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;There is one exception. &lt;/p&gt;

&lt;p&gt;In OR-based queries, SQLite may use multiple indexes, but in most cases, it selects a single index per table.&lt;/p&gt;

&lt;p&gt;Because of this limitation, index selection becomes a critical decision. &lt;/p&gt;

&lt;p&gt;SQLite tries to ensure that at least one useful index is applied to each table whenever possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  When Multiple Indexes Exist
&lt;/h2&gt;

&lt;p&gt;Consider a table with multiple indexes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;i1&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;i2&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now look at this query:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;SQLite has two choices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use index &lt;code&gt;i1&lt;/code&gt; to find rows where &lt;code&gt;x = 5&lt;/code&gt;, then filter &lt;code&gt;y = 6&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Use index &lt;code&gt;i2&lt;/code&gt; to find rows where &lt;code&gt;y = 6&lt;/code&gt;, then filter &lt;code&gt;x = 5&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both approaches are valid, but they may have very different costs.&lt;/p&gt;
&lt;h2&gt;
  
  
  How SQLite Chooses the Best Index
&lt;/h2&gt;

&lt;p&gt;SQLite estimates how much work each option will require and chooses the one with the lowest cost.&lt;/p&gt;

&lt;p&gt;The decision is based on heuristics such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How many rows are expected to match&lt;/li&gt;
&lt;li&gt;How selective the index is&lt;/li&gt;
&lt;li&gt;How much filtering is needed after lookup&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If statistical data is available, SQLite makes better decisions.&lt;/p&gt;

&lt;p&gt;This is where the &lt;code&gt;sqlite_stat1&lt;/code&gt; table comes into play. &lt;/p&gt;

&lt;p&gt;It stores information about how many rows are typically associated with a given column value. &lt;/p&gt;

&lt;p&gt;Using this data, SQLite can estimate which index will reduce the result set the most.&lt;/p&gt;

&lt;p&gt;The index that is expected to return fewer rows is usually preferred.&lt;/p&gt;
&lt;h2&gt;
  
  
  Forcing SQLite to Ignore an Index
&lt;/h2&gt;

&lt;p&gt;Sometimes, you may want to override SQLite’s choice.&lt;/p&gt;

&lt;p&gt;SQLite provides a subtle mechanism for this using the unary &lt;code&gt;+&lt;/code&gt; operator.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;+&lt;/code&gt; operator does nothing functionally, but it prevents SQLite from using the index on column &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This forces the optimizer to consider other indexes, such as &lt;code&gt;i2&lt;/code&gt; on column &lt;code&gt;y&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This is a lightweight way to guide the optimizer without changing query semantics.&lt;/p&gt;
&lt;h2&gt;
  
  
  Balancing WHERE and ORDER BY
&lt;/h2&gt;

&lt;p&gt;Index selection is not only about filtering rows. &lt;/p&gt;

&lt;p&gt;SQLite also considers sorting requirements.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now SQLite has a trade-off:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use an index on &lt;code&gt;x&lt;/code&gt; to filter efficiently&lt;/li&gt;
&lt;li&gt;Use an index on &lt;code&gt;y&lt;/code&gt; to avoid sorting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;SQLite evaluates both options and chooses the one that results in the fastest overall execution.&lt;/p&gt;

&lt;p&gt;This means sometimes SQLite may sacrifice a slightly less efficient filter to avoid an expensive sort operation.&lt;/p&gt;
&lt;h2&gt;
  
  
  When Sorting Cannot Use an Index
&lt;/h2&gt;

&lt;p&gt;If no suitable index can satisfy the ORDER BY clause, SQLite must sort the results manually.&lt;/p&gt;

&lt;p&gt;This is done using a &lt;strong&gt;temporary sorter&lt;/strong&gt;, which behaves like a transient index.&lt;/p&gt;

&lt;p&gt;The process looks like this:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;open&lt;/span&gt; &lt;span class="n"&gt;sorter&lt;/span&gt;
&lt;span class="k"&gt;where&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;begin&lt;/span&gt;
    &lt;span class="k"&gt;extract&lt;/span&gt; &lt;span class="n"&gt;required&lt;/span&gt; &lt;span class="n"&gt;columns&lt;/span&gt;
    &lt;span class="n"&gt;build&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt;
    &lt;span class="n"&gt;generate&lt;/span&gt; &lt;span class="n"&gt;sort&lt;/span&gt; &lt;span class="k"&gt;key&lt;/span&gt;
    &lt;span class="k"&gt;insert&lt;/span&gt; &lt;span class="k"&gt;into&lt;/span&gt; &lt;span class="n"&gt;sorter&lt;/span&gt;
&lt;span class="k"&gt;where&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="n"&gt;sort&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="k"&gt;each&lt;/span&gt; &lt;span class="n"&gt;sorted&lt;/span&gt; &lt;span class="n"&gt;entry&lt;/span&gt;
    &lt;span class="k"&gt;extract&lt;/span&gt; &lt;span class="k"&gt;data&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;result&lt;/span&gt;
&lt;span class="k"&gt;close&lt;/span&gt; &lt;span class="n"&gt;sorter&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This approach works, but it comes with a cost.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Additional memory usage&lt;/li&gt;
&lt;li&gt;Extra processing for sorting&lt;/li&gt;
&lt;li&gt;Potential performance overhead for large datasets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is why SQLite always tries to use an index for ORDER BY whenever possible.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why Index Selection Is So Important
&lt;/h2&gt;

&lt;p&gt;At this stage, multiple layers of optimization come together:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;WHERE clause determines candidate indexes&lt;/li&gt;
&lt;li&gt;Join ordering decides when a table is accessed&lt;/li&gt;
&lt;li&gt;Index selection decides how it is accessed&lt;/li&gt;
&lt;li&gt;ORDER BY may influence which index is preferred&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A single decision here can affect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Number of rows scanned&lt;/li&gt;
&lt;li&gt;Need for sorting&lt;/li&gt;
&lt;li&gt;Overall execution time&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Index selection is one of the most critical decisions in SQLite’s optimizer.&lt;/p&gt;

&lt;p&gt;Even when multiple indexes are available, SQLite carefully evaluates which one minimizes total work. &lt;/p&gt;

&lt;p&gt;It also balances filtering efficiency with sorting requirements to produce the fastest possible execution plan.&lt;/p&gt;

&lt;p&gt;Understanding how SQLite makes this decision helps you design better indexes and write queries that align with the optimizer.&lt;/p&gt;

&lt;p&gt;In the next part, we will explore &lt;strong&gt;GROUP BY and MIN/MAX optimizations&lt;/strong&gt;, where SQLite applies additional strategies to aggregate and summarize data efficiently.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyzvpkxm9mga1pweneahx.png" alt="git-lrc" width="800" height="109"&gt;&lt;/a&gt; &lt;br&gt;
 *AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production. &lt;/p&gt;

&lt;p&gt;git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.* &lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use. &lt;/p&gt;

&lt;p&gt;⭐ Star it on GitHub: &lt;br&gt;
 &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/HexmosTech" rel="noopener noreferrer"&gt;
        HexmosTech
      &lt;/a&gt; / &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;
        git-lrc
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Free, Unlimited AI Code Reviews That Run on Commit
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div&gt;
&lt;p&gt;| &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.da.md" rel="noopener noreferrer"&gt;🇩🇰 Dansk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.es.md" rel="noopener noreferrer"&gt;🇪🇸 Español&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fa.md" rel="noopener noreferrer"&gt;🇮🇷 Farsi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fi.md" rel="noopener noreferrer"&gt;🇫🇮 Suomi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ja.md" rel="noopener noreferrer"&gt;🇯🇵 日本語&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.nn.md" rel="noopener noreferrer"&gt;🇳🇴 Norsk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.pt.md" rel="noopener noreferrer"&gt;🇵🇹 Português&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ru.md" rel="noopener noreferrer"&gt;🇷🇺 Русский&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.sq.md" rel="noopener noreferrer"&gt;🇦🇱 Shqip&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.zh.md" rel="noopener noreferrer"&gt;🇨🇳 中文&lt;/a&gt; |&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;img width="60" alt="git-lrc logo" src="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;/a&gt;
&lt;br&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;git-lrc&lt;/h1&gt;
&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Free, Unlimited AI Code Reviews That Run on Commit&lt;/h2&gt;
&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.producthunt.com/products/git-lrc?embed=true&amp;amp;utm_source=badge-top-post-badge&amp;amp;utm_medium=badge&amp;amp;utm_campaign=badge-git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt" width="200" src="https://camo.githubusercontent.com/87bf2d4283c1e0aa99e254bd17fefb1c67c0c0d39300043a243a4aa633b6cecc/68747470733a2f2f6170692e70726f6475637468756e742e636f6d2f776964676574732f656d6265642d696d6167652f76312f746f702d706f73742d62616467652e7376673f706f73745f69643d31303739323632267468656d653d6c6967687426706572696f643d6461696c7926743d31373731373439313730383638"&gt;&lt;/a&gt;
 &lt;/p&gt;
&lt;br&gt;
&lt;a href="https://goreportcard.com/report/github.com/HexmosTech/git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="Go Report Card" src="https://camo.githubusercontent.com/e74c0651c3ee9165a2ed01cb0f6842c494029960df30eb9c24cf622d3d21bf46/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f4865786d6f73546563682f6769742d6c7263"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml" rel="noopener noreferrer"&gt;&lt;img alt="gitleaks.yml" title="gitleaks.yml: Secret scanning workflow" src="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml" rel="noopener noreferrer"&gt;&lt;img alt="osv-scanner.yml" title="osv-scanner.yml: Dependency vulnerability scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml" rel="noopener noreferrer"&gt;&lt;img alt="govulncheck.yml" title="govulncheck.yml: Go vulnerability check" src="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml" rel="noopener noreferrer"&gt;&lt;img alt="semgrep.yml" title="semgrep.yml: Static analysis security scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml/badge.svg"&gt;&lt;/a&gt; &lt;a rel="noopener noreferrer" href="https://github.com/HexmosTech/git-lrc/./gfx/dependabot-enabled.svg"&gt;&lt;img alt="dependabot-enabled" title="dependabot-enabled: Automated dependency updates are enabled" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FHexmosTech%2Fgit-lrc%2F.%2Fgfx%2Fdependabot-enabled.svg"&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;

&lt;p&gt;AI agents write code fast. They also &lt;em&gt;silently remove logic&lt;/em&gt;, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;git-lrc&lt;/code&gt; fixes this.&lt;/strong&gt; It hooks into &lt;code&gt;git commit&lt;/code&gt; and reviews every diff &lt;em&gt;before&lt;/em&gt; it lands. 60-second setup. Completely free.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;See It In Action&lt;/h2&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;See git-lrc catch serious security issues such as leaked credentials, expensive cloud
operations, and sensitive material in log statements&lt;/p&gt;
&lt;/blockquote&gt;

  
    
    

    &lt;span class="m-1"&gt;git-lrc-intro-60s.mp4&lt;/span&gt;
    
  

  

  


&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Why&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;🤖 &lt;strong&gt;AI agents silently break things.&lt;/strong&gt; Code removed. Logic changed. Edge cases gone. You won't notice until production.&lt;/li&gt;
&lt;li&gt;🔍 &lt;strong&gt;Catch it before it ships.&lt;/strong&gt; AI-powered inline comments show you &lt;em&gt;exactly&lt;/em&gt; what changed and what looks wrong.&lt;/li&gt;
&lt;li&gt;🔁 &lt;strong&gt;Build a&lt;/strong&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>webdev</category>
      <category>programming</category>
      <category>architecture</category>
      <category>database</category>
    </item>
    <item>
      <title>Inside SQLite’s Frontend: Join Table Ordering</title>
      <dc:creator>Athreya aka Maneshwar</dc:creator>
      <pubDate>Thu, 26 Mar 2026 20:45:48 +0000</pubDate>
      <link>https://forem.com/lovestaco/inside-sqlites-frontend-join-table-ordering-idi</link>
      <guid>https://forem.com/lovestaco/inside-sqlites-frontend-join-table-ordering-idi</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Maneshwar. I'm building git-lrc, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/em&gt;&lt;/p&gt; 

&lt;p&gt;Even if your WHERE clause is perfectly optimized, a bad join order can still make your query slow.&lt;/p&gt;

&lt;h2&gt;
  
  
  How SQLite Executes Joins
&lt;/h2&gt;

&lt;p&gt;SQLite uses a very simple but effective strategy for joins.&lt;/p&gt;

&lt;p&gt;It always executes joins as &lt;strong&gt;nested loops&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That means for a query like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;A&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;SQLite will do something like:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for each row in A:
    for each row in B:
        process the combination
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The important detail here is that the order of tables determines how these loops are nested.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first table becomes the &lt;strong&gt;outer loop&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;The last table becomes the &lt;strong&gt;inner loop&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the order in your FROM clause directly affects execution.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why Order Matters
&lt;/h2&gt;

&lt;p&gt;Nested loops can be very expensive if the outer loop has too many rows.&lt;/p&gt;

&lt;p&gt;For example, if table A has 1 million rows and table B has 1 million rows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A outer → B inner = 1M × 1M operations&lt;/li&gt;
&lt;li&gt;B outer → A inner = also large, but may differ depending on indexes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is to reduce the number of iterations as early as possible.&lt;/p&gt;
&lt;h2&gt;
  
  
  SQLite Doesn’t Always Follow Your Order
&lt;/h2&gt;

&lt;p&gt;Although the default behavior follows the FROM clause order, SQLite can &lt;strong&gt;reorder tables&lt;/strong&gt; if it finds a better execution plan.&lt;/p&gt;

&lt;p&gt;It uses a &lt;strong&gt;greedy algorithm&lt;/strong&gt; to decide the order.&lt;/p&gt;

&lt;p&gt;Instead of trying all possible combinations, it builds the order step by step:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First, pick the table that is cheapest to process&lt;/li&gt;
&lt;li&gt;Then pick the next cheapest&lt;/li&gt;
&lt;li&gt;Continue until all tables are placed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If two options are equally good, SQLite falls back to the original order in the query.&lt;/p&gt;
&lt;h2&gt;
  
  
  What “Cheapest” Means
&lt;/h2&gt;

&lt;p&gt;SQLite estimates cost using several factors:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Availability of indexes&lt;/li&gt;
&lt;li&gt;How selective those indexes are&lt;/li&gt;
&lt;li&gt;Whether sorting can be avoided&lt;/li&gt;
&lt;li&gt;Estimated number of rows to scan&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An index that reduces 1 million rows to 1 row is extremely valuable&lt;/li&gt;
&lt;li&gt;An index that reduces 1 million rows to 900,000 rows is not very useful&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where the &lt;code&gt;ANALYZE&lt;/code&gt; command becomes important. It collects statistics so SQLite can better estimate how effective an index is.&lt;/p&gt;
&lt;h2&gt;
  
  
  Index Nested Loop Joins
&lt;/h2&gt;

&lt;p&gt;If a table has an index on the join column, SQLite often places it as the &lt;strong&gt;inner loop&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This allows efficient lookups for each row from the outer loop.&lt;/p&gt;

&lt;p&gt;This strategy is called an &lt;strong&gt;index nested loop join&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead of scanning the entire inner table, SQLite uses the index to quickly find matching rows.&lt;/p&gt;
&lt;h2&gt;
  
  
  Special Cases: INNER vs OUTER Joins
&lt;/h2&gt;

&lt;p&gt;Inner joins are flexible.&lt;/p&gt;

&lt;p&gt;SQLite can freely reorder tables in inner joins because the result does not depend on order.&lt;/p&gt;

&lt;p&gt;Outer joins are different.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;LEFT OUTER JOIN&lt;/strong&gt; is not commutative, meaning order matters for correctness. Because of this, SQLite does not reorder outer joins.&lt;/p&gt;

&lt;p&gt;However, tables involved in inner joins around an outer join may still be reordered if it improves performance.&lt;/p&gt;
&lt;h2&gt;
  
  
  WHERE Clause Integration
&lt;/h2&gt;

&lt;p&gt;If you use ON or USING clauses in joins, SQLite internally converts them into additional WHERE clause conditions before optimization.&lt;/p&gt;

&lt;p&gt;This means all the WHERE clause optimizations you saw earlier still apply here.&lt;/p&gt;
&lt;h2&gt;
  
  
  Forcing Join Order
&lt;/h2&gt;

&lt;p&gt;In most cases, SQLite’s automatic reordering works well and you do not need to worry about it.&lt;/p&gt;

&lt;p&gt;But if you want to force a specific order, you can use a CROSS JOIN.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt; &lt;span class="k"&gt;CROSS&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;table1&lt;/code&gt; will always be the outer loop&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;table2&lt;/code&gt; will always be the inner loop&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This gives you manual control when needed.&lt;/p&gt;

&lt;p&gt;In the next part, we will look at &lt;strong&gt;index selection&lt;/strong&gt;, where SQLite decides exactly which index to use when multiple options are available.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyzvpkxm9mga1pweneahx.png" alt="git-lrc" width="800" height="109"&gt;&lt;/a&gt; &lt;br&gt;
 *AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production. &lt;/p&gt;

&lt;p&gt;git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.* &lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use. &lt;/p&gt;

&lt;p&gt;⭐ Star it on GitHub: &lt;br&gt;
 &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/HexmosTech" rel="noopener noreferrer"&gt;
        HexmosTech
      &lt;/a&gt; / &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;
        git-lrc
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Free, Unlimited AI Code Reviews That Run on Commit
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div&gt;
&lt;p&gt;| &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.da.md" rel="noopener noreferrer"&gt;🇩🇰 Dansk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.es.md" rel="noopener noreferrer"&gt;🇪🇸 Español&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fa.md" rel="noopener noreferrer"&gt;🇮🇷 Farsi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.fi.md" rel="noopener noreferrer"&gt;🇫🇮 Suomi&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ja.md" rel="noopener noreferrer"&gt;🇯🇵 日本語&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.nn.md" rel="noopener noreferrer"&gt;🇳🇴 Norsk&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.pt.md" rel="noopener noreferrer"&gt;🇵🇹 Português&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.ru.md" rel="noopener noreferrer"&gt;🇷🇺 Русский&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.sq.md" rel="noopener noreferrer"&gt;🇦🇱 Shqip&lt;/a&gt; | &lt;a href="https://github.com/HexmosTech/git-lrc/readme/README.zh.md" rel="noopener noreferrer"&gt;🇨🇳 中文&lt;/a&gt; |&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;img width="60" alt="git-lrc logo" src="https://camo.githubusercontent.com/948c8f2d5cf41b48985cd364d48c3a2dc9bfbfd42eab3e0a9a1b3e61f5f17ce3/68747470733a2f2f6865786d6f732e636f6d2f66726565646576746f6f6c732f7075626c69632f6c725f6c6f676f2e737667"&gt;&lt;/a&gt;
&lt;br&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;git-lrc&lt;/h1&gt;
&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Free, Unlimited AI Code Reviews That Run on Commit&lt;/h2&gt;
&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.producthunt.com/products/git-lrc?embed=true&amp;amp;utm_source=badge-top-post-badge&amp;amp;utm_medium=badge&amp;amp;utm_campaign=badge-git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt" width="200" src="https://camo.githubusercontent.com/87bf2d4283c1e0aa99e254bd17fefb1c67c0c0d39300043a243a4aa633b6cecc/68747470733a2f2f6170692e70726f6475637468756e742e636f6d2f776964676574732f656d6265642d696d6167652f76312f746f702d706f73742d62616467652e7376673f706f73745f69643d31303739323632267468656d653d6c6967687426706572696f643d6461696c7926743d31373731373439313730383638"&gt;&lt;/a&gt;
 &lt;/p&gt;
&lt;br&gt;
&lt;a href="https://goreportcard.com/report/github.com/HexmosTech/git-lrc" rel="nofollow noopener noreferrer"&gt;&lt;img alt="Go Report Card" src="https://camo.githubusercontent.com/e74c0651c3ee9165a2ed01cb0f6842c494029960df30eb9c24cf622d3d21bf46/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f4865786d6f73546563682f6769742d6c7263"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml" rel="noopener noreferrer"&gt;&lt;img alt="gitleaks.yml" title="gitleaks.yml: Secret scanning workflow" src="https://github.com/HexmosTech/git-lrc/actions/workflows/gitleaks.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml" rel="noopener noreferrer"&gt;&lt;img alt="osv-scanner.yml" title="osv-scanner.yml: Dependency vulnerability scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/osv-scanner.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml" rel="noopener noreferrer"&gt;&lt;img alt="govulncheck.yml" title="govulncheck.yml: Go vulnerability check" src="https://github.com/HexmosTech/git-lrc/actions/workflows/govulncheck.yml/badge.svg"&gt;&lt;/a&gt; &lt;a href="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml" rel="noopener noreferrer"&gt;&lt;img alt="semgrep.yml" title="semgrep.yml: Static analysis security scan" src="https://github.com/HexmosTech/git-lrc/actions/workflows/semgrep.yml/badge.svg"&gt;&lt;/a&gt; &lt;a rel="noopener noreferrer" href="https://github.com/HexmosTech/git-lrc/./gfx/dependabot-enabled.svg"&gt;&lt;img alt="dependabot-enabled" title="dependabot-enabled: Automated dependency updates are enabled" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FHexmosTech%2Fgit-lrc%2F.%2Fgfx%2Fdependabot-enabled.svg"&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;

&lt;p&gt;AI agents write code fast. They also &lt;em&gt;silently remove logic&lt;/em&gt;, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;git-lrc&lt;/code&gt; fixes this.&lt;/strong&gt; It hooks into &lt;code&gt;git commit&lt;/code&gt; and reviews every diff &lt;em&gt;before&lt;/em&gt; it lands. 60-second setup. Completely free.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;See It In Action&lt;/h2&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;See git-lrc catch serious security issues such as leaked credentials, expensive cloud
operations, and sensitive material in log statements&lt;/p&gt;
&lt;/blockquote&gt;

  
    
    

    &lt;span class="m-1"&gt;git-lrc-intro-60s.mp4&lt;/span&gt;
    
  

  

  


&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Why&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;🤖 &lt;strong&gt;AI agents silently break things.&lt;/strong&gt; Code removed. Logic changed. Edge cases gone. You won't notice until production.&lt;/li&gt;
&lt;li&gt;🔍 &lt;strong&gt;Catch it before it ships.&lt;/strong&gt; AI-powered inline comments show you &lt;em&gt;exactly&lt;/em&gt; what changed and what looks wrong.&lt;/li&gt;
&lt;li&gt;🔁 &lt;strong&gt;Build a&lt;/strong&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>webdev</category>
      <category>programming</category>
      <category>database</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
