<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tim Chapman on Medium]]></title>
        <description><![CDATA[Stories by Tim Chapman on Medium]]></description>
        <link>https://medium.com/@chapmantim?source=rss-2b333608d626------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*KAgdjNmbVP-WjBBa</url>
            <title>Stories by Tim Chapman on Medium</title>
            <link>https://medium.com/@chapmantim?source=rss-2b333608d626------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 16:06:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chapmantim/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Dude! Where’s my Clustered Index?!]]></title>
            <link>https://medium.com/google-cloud/dude-wheres-my-clustered-index-7738f994de06?source=rss-2b333608d626------2</link>
            <guid isPermaLink="false">https://medium.com/p/7738f994de06</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[relational-databases]]></category>
            <category><![CDATA[database-internals]]></category>
            <dc:creator><![CDATA[Tim Chapman]]></dc:creator>
            <pubDate>Wed, 16 Sep 2026 00:49:46 GMT</pubDate>
            <atom:updated>2026-09-16T00:49:46.520Z</atom:updated>
            <content:encoded><![CDATA[<h4>PostgreSQL for the SQL Server Pro</h4><h4>Heaps of fun ahead!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lpuvLJrO6LKU_5sPhn6yTQ.png" /></figure><p>In the SQL Server world, there are essentially 2 types of disk-based tables: heaps and clustered tables. A clustered table is one where there is a clustered index defined on the table and a heap is a table where there is no clustered index defined.</p><p>A clustered index defines the order in which the table is logically (and often times physically) ordered. Logical order is always maintained by the underlying B-tree index structure. The logical ordering ensures you’re always able to quickly look for the values you’re searching for. Physical ordering often matches the logical ordering, but things like page splits from data modifications can result in physical pages not matching the logical order — known as <a href="https://www.sqlskills.com/blogs/paul/where-do-the-books-online-index-fragmentation-thresholds-come-from/">logical fragmentation</a>.</p><p>Out in the wild, its very common to see most production tables in SQL Server “having” a clustered index. They’re great for finding rows in the table based on the clustered key and for range lookups for that key since the data is ordered. Below is a simplified graphic of a B-tree clustered index. For a seek, traversal always begins with the root page and the searches conclude once the value is found at the leaf level. Once the searched value is found at the leaf, the rest of the columns for the row are contained at that level. There is no duplication of data — the clustered index IS the table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*dV4upsYKXr2wT3IzSdATSg.png" /></figure><p>Clustered indexes are not a feature that exists in PostgreSQL. All PostgreSQL tables are heap tables. That is a super weird concept if you’re coming from a SQL Server background. Clustered indexes make things faster, so you <em>NEED</em> to have them, right? Well, not so fast.</p><p><em>Note: I am NOT talking about the CLUSTER command in PostgreSQL. CLUSTER physically reorders a table by an index once — it does not maintain the order like a clustered index in SQL Server does.</em></p><p>To understand this a bit better, we are going to have to dig into the weeds a bit. I am going to talk a bit today about how some of PostgreSQL’s Internals work. In the SQL Server world, there has been a ton of blog posts out there that show you how to view page contents using <a href="https://www.sqlskills.com/blogs/paul/real-world-story-of-dbcc-page-saving-the-day/">DBCC PAGE</a> and some other internal functions. So I will skip most of that for today’s writing. If you’re interested in more on this, I cover a fair amount of this in an article I wrote while I was at Microsoft. <a href="https://techcommunity.microsoft.com/blog/coreinfrastructureandsecurityblog/viewing-sql-server-non-clustered-index-page-contents/370420">You can view that article here</a>.</p><p>Lets begin by starting up our PostgreSQL container we created from <a href="https://medium.com/google-cloud/running-postgresql-in-a-container-7bece5d2676d">this article</a>.</p><pre>podman start pg-playground</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*73NKWwDC4xZeJ81d1qpENA.png" /></figure><p>Now lets log into the PostgreSQL instance in the container.</p><pre>podman exec -it pg-playground psql -U postgres</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*I66Kn4ZCF3tUBYCeMHQZAg.png" /></figure><p>Lets create a database to run our demos from. Aptly, we will name it heaptables.</p><pre>create database heaptables;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*W02rbhEA8hHevAe0RPVxtg.png" /></figure><p>We will need a tool to help us look at the underlying database structures. <a href="https://www.postgresql.org/docs/current/pageinspect.html">pageinspect</a> is similar in concept to SQL Server’s DBCC PAGE. It ships with PostgreSQL and exposes low-level functions that show you the raw byte layout and metadata for blocks (database pages). Also —the extension is available on most major cloud providers, but every function in pageinspect is superuser-only and managed services do not hand you a real superuser, so you’ll likely run into issues trying to run it there.</p><p><em>Note: think of a PostgreSQL extension as something that extends the engine’s functionality — kinda like trace flags in SQL Server. The biggest difference is that there are built-in and community extensions, which is really cool.</em></p><pre>create extension if not exists pageinspect;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*nKq6qDx1r6F_ug4NLVOVJg.png" /></figure><p>Now to create a table for the demo.</p><pre>create table customers(<br>customerid int generated always as identity,<br>email text not null, <br>fullname text not null);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*B1cBF0mFSvQC0M_VZ78d8g.png" /></figure><p>Next we will add a couple of records to the table. (I know, I know - this isn’t 3rd normal form. It will be just fine.)</p><pre>insert into customers(email,fullname)<br>values(&#39;chapmantim@google.com&#39;, &#39;Tim Chapman&#39;),<br>(&#39;bob@google.com&#39;, &#39;Bobby Tables&#39;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*1NDdbNtzsg3wbQpdWCmc3Q.png" /></figure><p>And to finish up with the demo prep, lets put a secondary (non-clustered) index on our heap customers table.</p><pre>create index idx_customers_email ON customers(email);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*nR2TVXthP6Xm2iTBsHymPA.png" /></figure><p><em>Note: secondary indexes in PostgreSQL are, for all intents and purposes, the same as non-clustered indexes in SQL Server. They contain a copy of the data in the underlying table - a copy that is optimized for searching and sorting.</em></p><p>In the following query, I reference the internal/hidden ctid column — which stands for “current tuple id” and it represents the physical location of a row version on disk. It is formatted as (block-number, offset-number).</p><p><em>Note: ctid in PostgreSQL is very similar in concept to passing the value %%physloc%% to the function </em><a href="https://www.sqlskills.com/blogs/paul/sql-server-2008-new-undocumented-physical-row-locator-function/"><em>sys.fn_PhysLocFormatter </em></a><em>in SQL Server.</em></p><pre>select ctid, * from customers;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*PcXHs0GXveqSlACvvfPqMg.png" /></figure><p>This output tells us that both rows are on the same block/page (block 0 in this case) and the offset is the pointer to the row in the table.</p><p>In SQL Server, page numbers are unique inside a single file. Each data file (mdf/ndf) is divided into 8KB pages numbered consecutively from 0, and every file starts its own count at 0 again. So a page address has two parts, FileID:PageNumber, as in 1:352. The file ID is what makes the address unique across the database.</p><p>A filegroup can hold several files, and SQL Server spreads new allocations across them <a href="https://www.sqlskills.com/blogs/paul/investigating-the-proportional-fill-algorithm/">using proportional fill</a>. So one table’s extents can end up scattered over several files. The Index Allocation Map (IAM) page covers one 4GB interval in one file, and SQL Server links those pages into a chain that records which extents belong to which allocation unit.<br> <br>PostgreSQL, by contrast, is relation-centric. Every table gets its own underlying file on disk. I’ll say that again - <strong>every table (and index) in PostgreSQL gets its own file on disk</strong>. A crazy concept for us coming from SQL Server.</p><p>Every table in PostgreSQL starts at Block 0. A ctid like (0, 2) does not need a file ID because the block number is already scoped to that specific relation.</p><p>In terms of how disk space is allocated, SQL Server allocates 64 KB extents (eight contiguous 8 KB pages) and records their allocation in two bitmaps, GAM and SGAM; a separate structure — the Page Free Space page (PFS), uses one byte per page to track how full each individual page is. PostgreSQL has no concept of extents. It checks the relation’s <a href="https://www.postgresql.org/docs/current/storage-fsm.html">Free Space Map</a> (_fsm) for room in existing pages. When they’re all full, it extends the file by appending new 8 KB blocks — one at a time in the simple case, or up to 64 at once during bulk inserts.</p><p>Once a PostgreSQL table (or index) passes 1 GB in size, the engine splits the physical relation into gigabyte-sized segment files. The first segment keeps the plain relfilenode name; later ones are relfilenode.1, relfilenode.2, and so on. Block numbering stays globally linear across them, so locating a block is integer math — at the default 8 KB block size and 1 GB segment, that’s 131072 blocks per segment:</p><p>• Segment File: BlockNumber / 131072<br>• Byte Offset: (BlockNumber % 131072) * 8192</p><p>OK, since I have mentioned them its a good time to talk a bit more about SQL Server&#39;s Page Free Space pages and PostgreSQL’s Free Space Map pages as they are very relevant to this discussion today.</p><p>When a record is INSERTed into either engine, they need to figure out where that row can fit. In SQL Server that job belongs to <a href="https://learn.microsoft.com/en-us/sql/relational-databases/pages-and-extents-architecture-guide?view=sql-server-ver17">Page Free Space (PFS) pages</a>, which live inside the data file itself at page 1 and every 8,088 pages after that. Each PFS page holds one byte for every page it tracks, and that byte does two separate jobs. First it records whether the page is allocated at all, which matters for every object in the database. Second it records roughly how full the page is, in five buckets: empty, 1–50%, 51–80%, 81–95%, and 96–100%. SQL Server only maintains that second job for heap and text/LOB pages, because a B-tree’s insertion point is dictated by the index key rather than by available space. Finding a page is then a two-structure lookup: the IAM chain identifies which extents belong to the allocation unit, and the PFS bytes for those extents say which page has room. If no page in those extents has room, SQL Server allocates a new extent. B-tree indexes use that same lookup whenever they need a new page, such as during a page split.</p><p>PostgreSQL does the same work with a Free Space Map (FSM) page, kept it in its own separate file alongside the relation file, named after the filenode with an _fsm suffix. Every heap and index object gets one (except hash indexes), so unlike SQL Server, PostgreSQL tracks free space for B-tree indexes too, which is how whole index pages emptied by VACUUM get recycled (a discussion for a different day). The FSM is a tree of pages, and inside each page the bytes form a binary tree (NOT a B-tree) in which every parent holds the largest free-space value among its children, so the engine navigates from the root straight to a page with enough room. SQL Server splits the operation across two structures — IAM for which extents belong to the object, PFS for whether a page has space — while PostgreSQL folds both into a single searchable tree.</p><p>OK, back to demos. Lets next use the bt_page_items PostgreSQL function to dump out the data in the secondary index we created earlier.</p><pre>SELECT itemoffset, ctid as heap_row_pointer, data<br>FROM bt_page_items(&#39;idx_customers_email&#39;, 1);</pre><p>Here we see the index entry offset (itemoffset) and the ctid pointer to where the row exists in the base table (heap). The data column is hex data, which is not terribly useful for our purposes here, so I’ll need to convert it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*SgxgGtDjzoD5PQpydQltOQ.png" /></figure><p>We can use this query to do the conversion. There are a couple of ways to do this, but I’ll just show this one today.</p><pre>WITH items AS (<br> SELECT itemoffset, ctid, decode(replace(data, &#39; &#39;, &#39;&#39;), &#39;hex&#39;) AS b<br> FROM bt_page_items(&#39;idx_customers_email&#39;, 1)<br> )<br> SELECT <br> itemoffset, <br> ctid AS heap_row_pointer,<br> convert_from(substr(b, 2, (get_byte(b, 0) &gt;&gt; 1) - 1), &#39;UTF8&#39;) AS email<br> FROM items;</pre><p>Now that the conversion is done, we can see the email column as part of the index. We see that the row in the index for chapmantim@google.com is row 2 in the secondary index but points back to row 1 in the heap table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*VIGXmcic047YE-LxSQZTiw.png" /></figure><p>OK, lets have a look at how these lookups present themselves in a query execution plan. (I’ll dig deep into PostgreSQL execution plans in a future post.) The query below asks for customerid and fullname, neither of which live in idx_customers_email, so PostgreSQL has no choice but to go out to the heap to grab the extra column data. EXPLAIN (ANALYZE, BUFFERS) shows us which plan the engine picked and, more importantly, how many pages it had to touch from disk or memory to get there.</p><pre>SET enable_seqscan = off;<br> <br>EXPLAIN (ANALYZE, BUFFERS)<br>SELECT customerid, email, fullname<br>FROM customers<br>WHERE email = &#39;chapmantim@google.com&#39;;</pre><p>I turn sequential scans off before running this, with SET enable_seqscan = off. On a table this small PostgreSQL would likely otherwise skip the index and read the whole table, which breaks my demo. The setting does not ban sequential scans (the docs are clear that suppressing them entirely is impossible), it just prices them high enough that the planner reaches for the index instead. Reset it with RESET enable_seqscan afterward. On a production-sized table you would never need it.</p><p>The text based plan is show in the graphic below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K8XQ09D-KqpZgmP_4qW_VQ.png" /></figure><p>What I want to show in the execution plan is the engine pulling what it can from the secondary index and then going out to the base heap table for the columns the index does not include. In SQL Server that second step is a bookmark lookup — a Key Lookup against the clustered index, or a RID Lookup against a heap (more on this in a minute) and the optimizer implements this with a nested loop operator. These are very common to see and they can be very expensive.</p><p>Scanning a table is a fixed cost - all of the pages in the table are read once. A lookup is iterative, once per qualifying row, and past a certain point that iteration costs dramatically more than just reading the entire table. The optimizer knows this and will abandon your index seek for a scan once it estimates enough rows coming back. My good friend <a href="https://www.sqlskills.com/blogs/kimberly/category/the-tipping-point/">Kimberly Tripp named this the tipping point</a>, and it arrives at a far smaller fraction of the table than most people expect. Alas, this is not a chat about SQL Server performance tuning.</p><p>In the PostgreSQL execution plan above, the Index Scan using idx_customers_email on customers is doing the seek and the lookup together. The Index Cond is the seek half, where the engine walks the B-tree for idx_customers_email down to leaf block 1 and finds the entry for ‘<a href="/service/mailto:chapmantim@google.com">chapmantim@google.com</a>’. That is the row you already saw with bt_page_items at itemoffset 2, and sitting right beside the key, ctid = (0,1). The ctid is a physical address: block 0, line pointer 1. Since customerid and fullname are not in the index, the engine follows that address into the heap, reads line pointer 1 out of the array just past the page header, and pulls the row. Same node, no second operator.</p><p>Buffers counts the pages PostgreSQL had to touch to answer the query. Here shared hit=2: PostgreSQL touched two pages, and found both already sitting in shared_buffers (similar in concept to SQL Server&#39;s buffer pool), so it never had to ask the operating system for either one. No physical reads at all. One page was the index leaf holding the key and the ctid. The other was heap block 0 holding the row. That is the entire cost of the lookup. Note that the plan reports a total, not a breakdown.</p><p>So why is PostgreSQL fine without clustered indexes? Look again at what that lookup actually costs. In SQL Server, every non-clustered index stores the clustered key as its row locator, so a Key Lookup is a second B-tree traversal — root to intermediate to leaf — just to reach the row. PostgreSQL stored a ctid instead, which is a physical address. Block 0, line pointer 1. There is no tree to walk. The engine reads the block and takes the row.</p><p><em>Note: when a table in SQL Server is a heap, the semantics for record lookups is very similar to how it works in PostgreSQL. A non-clustered index on a heap stores a RID — FileID:PageID:SlotID — and the lookup jumps straight to that physical address with no second B-tree traversal. A ctid does the same job, minus the file number, since PostgreSQL scopes block numbers to the relation.</em></p><p>As with everything with computing, there is a trade-off. In SQL Server that row locator is static — as long as the clustered key values do not change, the non-clustered indexes never notice. A ctid is a physical address, and it is only good for one version of the row. PostgreSQL never updates in place — every UPDATE writes a new version of the row at a new ctid and leaves the old one sitting there for any transaction still entitled to read it. A new ctid means every index on the table needs a new entry, including indexes on columns your UPDATE never touched. That is what you trade for skipping the second B-tree traversal. (MVCC is getting its own post. There is a lot going on down there.)</p><p>PostgreSQL does have an optimization called Heap-Only Tuple (HOT), which skips the index writes entirely when the table update doesn’t touch any indexed columns and the new version fits on the same page.</p><p>The other trade-off is that giving up guaranteed physical ordering costs you on range scans. In exchange, every index is the same kind of index. There is no key to choose that decides how the table is ordered, and no wide clustered key getting copied into every secondary index. When you do need a covering index, PostgreSQL gives you INCLUDE columns and index-only scans. When you really do want physical order, CLUSTER will do a one-time pass — just remember it takes an exclusive lock and rewrites the table, so it is a maintenance-window job, not a tuning knob.</p><h4>Wrapping Up</h4><p>Today we dug into PostgreSQL’s lack of Clustered Index and why it is OK that they do not have them. Every table is a heap, every row has a physical address, and every index points at that address the same way.</p><p>That does not mean there is nothing left to tune. It means the tuning moved somewhere else, to covering indexes, to VACUUM, and to the free space map doing its job. We will get into all of that in future articles.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7738f994de06" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/dude-wheres-my-clustered-index-7738f994de06">Dude! Where’s my Clustered Index?!</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running SQL Server in a Linux Container]]></title>
            <link>https://medium.com/google-cloud/running-sql-server-in-a-linux-container-0b0bbb0223d6?source=rss-2b333608d626------2</link>
            <guid isPermaLink="false">https://medium.com/p/0b0bbb0223d6</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[sql-server]]></category>
            <dc:creator><![CDATA[Tim Chapman]]></dc:creator>
            <pubDate>Fri, 28 Aug 2026 06:14:36 GMT</pubDate>
            <atom:updated>2026-08-28T06:14:36.155Z</atom:updated>
            <content:encoded><![CDATA[<h4>PostgreSQL for the SQL Server Pro</h4><h4>Understanding SQL PAL architecture and spinning up a local SQL Server container playground</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sbWOGqtharuNr_csVCNwiA.png" /></figure><p>About 10 years ago I was traveling to Redmond to attend an internal Microsoft training event called TechReady. These were huge events, with thousands of engineers attending to be up-skilled by the various Product Groups for their technology focus. Amazing events. I remember there was a pre-event full-day (or maybe 2 days, I can&#39;t remember) training session with the title something along the lines of ‘Project Helsinki’. It sounded neat, though I had really no idea what it was. But it was a reason to be out in Redmond early during July, so I was all for it. Little did I know I was signing up to <strong>learn how to run SQL Server on Linux</strong>! At that time, it seemed like an insane concept.</p><p>For more than two decades, SQL Server was deeply and unapologetically tied to the Windows NT kernel. It relied on Windows APIs, the Windows security model, and Windows clustering. The idea of running SQL Server on Red Hat, Ubuntu, or inside a Linux container seemed practically impossible without rewriting millions of lines of code. (Honestly — around that time I had no clue what a container was.)</p><p>Yet in late 2017, Microsoft shipped SQL Server 2017 (developed under that fun project name “Helsinki”), running natively on Linux or in <a href="https://www.docker.com/">Docker</a> containers. Today, running SQL Server on Linux containers is one of the most effective ways to stand up isolated test instances, validate query performance, and run continuous integration pipelines without spinning up heavy virtual machines.</p><p>Since this series is focusing on translating concepts between SQL Server and PostgreSQL, we need a solid playground for both engines. We previously looked at <a href="https://medium.com/google-cloud/running-postgresql-in-a-container-7bece5d2676d">spinning up PostgreSQL in a container</a>. SQL Server in a Linux container is just as fast to stand up, but how it works under the hood is a totally different story.</p><h3>How can SQL Server run on Linux?</h3><p>To understand how SQL Server runs on Linux we first must dig into the engineering challenge Microsoft faced to make it so. SQL Server is a MASSIVE code-base, containing tens of millions of lines of C and C++ (and, in some cases, Assembler). You’d be shocked how much code gets executed to do even the simplest things.</p><p>So, rewriting the storage engine, query optimizer, and execution engine to use native POSIX system calls would have taken a decade and introduced enough difficult challenges that porting it likely wouldn’t have been worth it. Maintaining two completely separate code-bases — one for Windows and one for Linux — would have been an engineering nightmare.</p><p><em>Note: POSIX stands for Portable Operating System Interface and is a set of rules for system calls, APIs and OS behaviors — most commonly used with the Linux and Unix operating systems.</em></p><p>Instead of a rewrite, Microsoft used a layered architecture built on two key components: the SQL Operating System (SOS) and the Platform Abstraction Layer (SQL PAL), inspired by <a href="https://www.microsoft.com/en-us/research/project/drawbridge/">Microsoft Research’s Project Drawbridge</a>. (For additional architectural background, see Microsoft’s <a href="https://www.microsoft.com/en-us/sql-server/blog/2016/12/16/sql-server-on-linux-how-introduction/">SQL Server on Linux: How? Introduction</a>).</p><h3>1. SQL Operating System (SOS)</h3><p>Back in SQL Server 2005, Microsoft introduced SQLOS (later known as SOS). SQL Server stopped relying directly on the Windows kernel for day-to-day thread scheduling, memory node management, and asynchronous I/O completion. Instead, SOS took over cooperative non-preemptive scheduling, memory allocation tracking, and resource management within user mode.</p><p><em>Note: Operating systems use preemptive scheduling, meaning the OS kernel forcibly interrupts threads to ensure no single application monopolizes the CPU. In contrast, the SQL Operating System (SOS) uses cooperative (non-preemptive) scheduling within its user-mode engine. Worker threads voluntarily yield the CPU once they hit their quantum or if they need to wait for a resource(like waiting for a lock, latch, or disk I/O) so the engine can manage query concurrency with minimal OS context-switching overhead.</em></p><p>Because the SQL Server relational engine already talked to SOS rather than making raw Win32 calls for scheduling and memory, the top layer of the engine was already mostly decoupled from the underlying operating system.</p><h3>2. The Platform Abstraction Layer (SQL PAL)</h3><p>Instead of rewriting millions of lines of code to speak Linux, Microsoft created a layer between SQL Server and Linux, named SQL PAL (Platform Abstraction Layer). Think of SQL PAL as a lightweight, in-process translation layer. It sits directly inside the database process to provide the exact Windows APIs the engine expects, while seamlessly translating those requests into native Linux system calls underneath.</p><p>As far as the core SQL Server engine is concerned, nothing has changed. When the engine allocates memory, reads a data file from disk, or coordinates worker threads, it makes the exact same calls it has always made. SQL PAL intercepts those requests directly inside the process address space and works with a thin Linux host extension to translate them into native Linux operations:</p><ul><li><strong>Memory Management:</strong> Memory requests and page reservations are mapped directly to native Linux memory allocation.</li><li><strong>Disk I/O:</strong> Asynchronous database reads, log writes, and page flushes are routed straight to the native Linux filesystem.</li><li><strong>Threading &amp; Locking:</strong> SQL Server worker threads and internal locks map straight to real Linux threads and native OS locks.</li></ul><p>Because SQL PAL runs as native compiled code directly inside the SQL Server process, you aren’t running an emulator like Wine or a virtual machine. The core engine executes as native machine code, while SQL PAL simply handles the operating system calls underneath.</p><h3>The Result: Single-Process Execution</h3><p>Because of this abstraction layer, the entire database engine runs on Linux as a single, multi-threaded process.</p><p>If you are familiar with PostgreSQL, this might seem kinda weird. PostgreSQL uses a multi-process architecture — spawning a separate child PostgreSQL process for every client connection. Because of that, database engineers often assume Linux databases only use processes and that threads are a Windows-only concept.</p><p>In reality, Linux has first-class kernel multi-threading. When SQL Server spins up worker threads, it uses the Linux clone() system call to create real OS threads that share the exact same process memory space.</p><p><em>(We will dig much deeper into the world of threads vs. processes architecture in a future post, but for our purposes here it is helpful to know that SQL Server’s multi-threaded engine design translates directly to native Linux threads).</em></p><h3>What Works, What Doesn’t, and some Caveats</h3><p>To understand what works and what doesn’t on Linux, it helps to understand what Win32 actually is. Win32 is the core application programming interface (API) that Windows software has used for decades to interact with the operating system — handling low-level duties like memory allocation, file access, security tokens, and thread scheduling.</p><p>Because SQL PAL provides the essential Win32 surface area directly inside the Linux process, the core relational engine runs identically on Linux. The query optimizer, storage engine, transaction logging, indexing, and T-SQL execution all behave exactly as they do on Windows.</p><p>However, over its long history on Windows, SQL Server also built dependencies on external Windows operating system features outside the core engine — like Windows clustering services, Active Directory domain joins, MAPI mail subsystems, and proprietary filesystem drivers. Those external Windows components don’t exist on Linux, which leads to a few important caveats.</p><h3>What Works Identically</h3><ul><li>Core Database Engine: Full T-SQL support, Clustered and Non-Clustered Indexes, Query Optimizer, and Execution Engine.</li><li>Advanced Storage and Engine Features: In-Memory OLTP (Hekaton), Clustered and Non-Clustered Columnstore Indexes, Table Partitioning, Data Compression, and Query Store.</li><li>Security: Transparent Data Encryption (TDE), Always Encrypted, Row-Level Security, and Dynamic Data Masking.</li><li>High Availability: Always On Availability Groups. On standalone Linux VMs, AG failover is orchestrated by Pacemaker and Corosync instead of Windows Server Failover Clustering (WSFC). In container environments, you can run clusterless (read-scale) Availability Groups.</li><li>Tooling &amp; Observability: Dynamic Management Views (DMVs), Dynamic Management Functions (DMFs), Extended Events (XEvents), and SQL Server Agent for background jobs.</li><li>Backup and Restore: Database backup files (.bak) are fully binary-compatible. You can take a native backup of a database running on SQL Server for Windows and restore it directly onto SQL Server on Linux, and vice versa.</li></ul><h3>What Is Not Supported or Has Caveats</h3><ul><li>FileStream and FileTable: These rely on Windows-specific filesystem drivers that don’t exist on Linux, making both features completely unsupported.</li><li>Active Directory in Containers: While supported on Linux VMs using Kerberos, setting up domain authentication in local containers adds a lot of extra hassle. For a local container sandbox, standard SQL logins (like sa) are the easiest way to go.</li><li>Extended Stored Procedures &amp; xp_cmdshell: Legacy Windows C++ DLLs (sp_addextendedproc) won’t load on Linux. If you enable xp_cmdshell, it executes a Linux /bin/sh shell inside the container instead of Windows cmd.exe.</li><li>Database Mail: Database Mail works on Linux, but configuration must be scripted via T-SQL stored procedures (msdb.dbo.sp_send_dbmail and sysmail_add_account_sp) rather than the SSMS graphical wizard.</li><li>SSAS and SSRS: Analysis Services and Reporting Services remain Windows-only and aren’t included in Linux packages or container images.</li><li>File Path Case Sensitivity: While SQL Server table and column names are typically case-insensitive, the Linux filesystem is strictly case-sensitive. If you run a RESTORE or ATTACH command with mismatched casing in the path (MyDb.mdf vs mydb.mdf), Linux will return a file-not-found error.</li></ul><h3>Spinning up SQL Server in a Container</h3><p>Running SQL Server in a container is the fastest way to get an isolated sandbox up and running on your local machine. We will use Podman on Linux, but the commands work almost identically with Docker.</p><p>If you just need a quick, throwaway instance for running test queries:</p><pre># Using Podman:<br>podman run --name sql-playground \<br>-e &quot;ACCEPT_EULA=Y&quot; \<br>-e &quot;MSSQL_SA_PASSWORD=Password12345&quot; \<br>-e &quot;MSSQL_PID=Developer&quot; \<br>-p 1433:1433 \<br>-d mcr.microsoft.com/mssql/server:2025-latest</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*6BQCErbdqRmjNVZgYFhW7Q.png" /></figure><p>Here is a breakdown of what these flags do:</p><ul><li>— name sql-playground: Assigns a friendly name so you don’t have to manage long container IDs.</li><li>-e “ACCEPT_EULA=Y”: Confirms your acceptance of the End User License Agreement. The container will refuse to start without this.</li><li>-e “MSSQL_SA_PASSWORD=Password12345”: Sets the system administrator (sa) password. SQL Server enforces password complexity (minimum 8 characters, uppercase, lowercase, numbers, and symbols).</li><li>-e “MSSQL_PID=Developer”: Specifies the edition. The default is Developer (which provides full Enterprise Edition feature parity for development and testing). You can also specify Express, Standard, Enterprise, or a commercial product key.</li><li>-p 1433:1433: Maps port 1433 inside the container to port 1433 on your host.</li><li>-d: Runs the container detached in the background.</li><li>mcr.microsoft.com/mssql/server:2025-latest: Pulls the official SQL Server 2025 container image from the Microsoft Container Registry (MCR).</li></ul><p><em>(Note: SQL Server has a hard minimum requirement of 2GB (2048 MB) of RAM to start up. If your container engine or virtual machine is constrained below 2GB, the container will exit immediately on launch).</em></p><h3>2. Adding Persistent Storage and the Non-Root User Gotcha</h3><p>As I mentioned in my previous post about setting up PostgreSQL in a container, container storage is ephemeral. If you delete the container, your databases disappear. To persist your data across container updates, you need to mount a host directory to `/var/opt/mssql`.</p><p><em>Note on Linux Paths: If you’re wondering why SQL Server lives in /var/opt/mssql, Linux follows a standard directory structure. Third-party application binaries live in /opt — think of /opt/mssql as your C:\Program Files folder for the engine executables. Variable runtime data like database files, transaction logs, and error logs live in /var/opt — think of /var/opt/mssql as your MSSQL\DATA and MSSQL\Log directories.</em></p><p>Starting in SQL Server 2019 CU3, Microsoft updated container images to run as an unprivileged, non-root user (`mssql`, UID 10001). When you mount a local host folder, that directory is owned by your host user account. If the container process cannot write to it, SQL Server will fail to create `master.mdf` and `tempdb.mdf`, and the container will exit immediately.<br> <br> In Linux, changing directory ownership normally requires running the `chown` (change owner) command with `sudo`. With rootless Podman, you don’t have to manually manage host permissions — you handle this automatically by adding `:Z,U` to the volume flag:</p><p>Here is how to set up persistent storage properly:</p><pre># 1. Create a local directory on your host for SQL Server files<br>mkdir -p ~/sqldata<br><br># 2. Spin up the container with the volume mount and memory limit<br>podman run --name sql-playground \<br>-e &quot;ACCEPT_EULA=Y&quot; \<br>-e &quot;MSSQL_SA_PASSWORD=Password12345&quot; \<br>-e &quot;MSSQL_PID=Developer&quot; \<br>-e &quot;MSSQL_MEMORY_LIMIT_MB=4096&quot; \<br>-v ~/sqldata:/var/opt/mssql:Z,U \<br>-p 1433:1433 \<br>-d mcr.microsoft.com/mssql/server:2025-latest</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*llenlYH47KACqiDifVGLfQ.png" /></figure><p>Details of note in this command:</p><ol><li>-v ~/sqldata:/var/opt/mssql:Z,U: Mounts the host folder to the container’s data directory. The :U flag tells Podman to automatically run a recursive change owner (chown) on the host directory to match the unprivileged mssql service account (UID 10001) inside the container namespace, while :Z configures private SELinux labeling on systems like RHEL, Fedora, and CentOS.</li></ol><p><em>(Note for Docker users: The :U flag is a Podman-specific extension. If you are using Docker instead of Podman, manually set permissions on your host directory first by running sudo chown -R 10001:0 ~/sqldata, then mount it using standard :z syntax: -v ~/sqldata:/var/opt/mssql:z).</em></p><p>2. -e “MSSQL_MEMORY_LIMIT_MB=4096”: Tells SQL Server’s internal memory manager to cap memory consumption at 4GB. Inside containers, host memory detection can occasionally misread total host RAM, so setting an explicit limit is a best practice.</p><p>Lets double-check to make sure our container is running:</p><pre># Have a look at all containers running on the machine<br>podman ps -a</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R0J8ntU_aCTJ6PCGC6I4Zg.png" /></figure><h3>Connecting via Command Line</h3><p>Our container has sqlcmd already available, so we can call it via podman exec to connect. From there I just run a simple SELECT @@VERSION to get the version of the SQL Server instance.</p><pre>podman exec -it sql-playground /opt/mssql-tools18/bin/sqlcmd \<br>-S localhost -U sa -P &quot;Password12345&quot; -C</pre><p><em>(Note: In modern versions of sqlcmd and ODBC Driver 18, encryption is enabled by default. The -C flag tells sqlcmd to trust the server certificate for local testing).</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*42fI-I4Fi4Wjht1vuQus7Q.png" /></figure><h3>Connecting via SQL Server Management Studio (SSMS)</h3><p>Time to give our trusty tool, SQL Server Management Studio, a try. Here we are running SQL Server on Linux, but want to connect via SSMS on Windows. To make this easy, I’ll just connect via the IP of my Linux machine.</p><p>In the SSMS Connect to Server dialog, set:</p><ul><li>Server type: Database Engine</li><li>Server name: either the name of your Linux machine or its IP address. In my case it is 172.24.8.250 (yours will almost certainly be different).</li><li>Authentication: SQL Server Authentication</li><li>Login: sa</li><li>Password: Password12345 (or the password configured in MSSQL_SA_PASSWORD).</li><li>Certificate Trust: In SSMS 19 and SSMS 20, encryption is required by default. Because the container generates a self-signed certificate during startup, click the Options button and check the “Trust server certificate” box (or set Encryption to Optional). If you skip this, SSMS will refuse to connect because the certificate is not signed by a trusted root authority.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*NTgTXgG9QTYID8KGJ-EWTw.png" /></figure><p>Once connected, Object Explorer works identically to a Windows installation. You can browse databases, open Activity Monitor, check SQL Server Agent jobs, manage logins, view server properties, and run queries.</p><h3>Lets run some Queries</h3><p>Once connected, let’s run a few diagnostic queries to see how the engine views its Linux host.</p><p>First, lets check out the version of SQL Server. Here we can see this is running on Ubuntu Linux. This should return the same as the call from podman exec.</p><pre>SELECT @@VERSION<br>GO</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*OR5XVd_K6MMaDpG6A5E0FQ.png" /></figure><p>Next, lets query the DMV <a href="https://learn.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-objects/sys-dm-os-host-info-transact-sql?view=sql-server-ver17">sys.dm_os_host_info</a> to view the host details. Similar information to what was returned from @@VERSION, but with the addition of the host CPU architecture.</p><pre>SELECT<br>  host_platform,<br>  host_distribution,<br>  host_architecture<br>FROM sys.dm_os_host_info;<br>GO</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*rOJcGOyi8Myl9ujoZBfhQA.png" /></figure><p>Lastly, lets query <a href="https://learn.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-objects/sys-dm-os-sys-info-transact-sql?view=sql-server-ver17">sys.dm_os_sys_info</a> for operating system info. One neat thing this query returns is the fact that this version of SQL is specifically running on a Linux Container. Very cool!</p><pre>SELECT<br>  cpu_count,<br>  hyperthread_ratio,<br>  physical_memory_kb / 1024 AS physical_memory_mb,<br>  committed_kb / 1024 AS committed_mb,<br>  container_type_desc<br>FROM sys.dm_os_sys_info;<br>GO</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*_Um7P_yJN-eUtrnTqry7Cg.png" /></figure><h3>Wrap Up</h3><p>SQL Server in a Linux container runs the exact same relational engine, query optimizer, and buffer pool as Windows. By decoupling the engine with the SQL Operating System (SOS) and routing OS calls through SQL PAL, Microsoft brought the full database engine to Linux without maintaining two separate code-bases.</p><p>Here is what we covered:</p><ul><li><strong>The Architecture:</strong> SQL Server talks to SQL PAL within its user-mode address space, while a thin Linux host extension maps memory, disk I/O, and threading directly to native Linux operations.</li><li><strong>The Process Model:</strong> Unlike PostgreSQL’s multi-process architecture, SQL Server runs on Linux as a single process (sqlservr) powered by native Linux kernel threads created via clone().</li><li><strong>Container Setup &amp; Permissions:</strong> Spinning up an instance with Podman or Docker is fast, but persistent volumes require setting ownership to UID 10001 (mssql) because modern container images run non-root by default.</li><li>Engine Parity: The core engine, indexing, T-SQL syntax, and diagnostic views are identical. Querying sys.dm_os_host_info confirms the Linux host, while sys.dm_os_sys_info explicitly identifies the container runtime.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0b0bbb0223d6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/running-sql-server-in-a-linux-container-0b0bbb0223d6">Running SQL Server in a Linux Container</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running PostgreSQL in a Container]]></title>
            <link>https://medium.com/google-cloud/running-postgresql-in-a-container-7bece5d2676d?source=rss-2b333608d626------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bece5d2676d</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[podman]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[sql-server]]></category>
            <dc:creator><![CDATA[Tim Chapman]]></dc:creator>
            <pubDate>Fri, 21 Aug 2026 01:11:37 GMT</pubDate>
            <atom:updated>2026-08-21T12:43:53.290Z</atom:updated>
            <content:encoded><![CDATA[<h4>PostgreSQL for the SQL Server Pro</h4><h4>Let’s build a zero-footprint PostgreSQL playground in under 10 minutes!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JM3yEzdbAYipFALssLwouw.jpeg" /></figure><p>Today I am going to look at the options for getting a local version of PostgreSQL up and running for testing. Most of the posts in this series will focus either on Google’s Cloud SQL for PostgreSQL or AlloyDB for PostgreSQL, but it is important to understand how to get a local PG database running to help understand the internals better. While this is a series focused both on SQL Server and PostgreSQL, I will focus on running PostgreSQL from a container today. I’ll show you how to run SQL Server from a container on Linux in the future. No Windows GUI installs today. :)</p><h4>Why Run a Database in a Container?</h4><p>Containers package an application along with its binaries, libraries, and configuration files into a single, portable unit. Because they share the host operating system’s kernel rather than virtualizing hardware, containers are lightweight, fast to start, and consume minimal resources. For database development, the greatest advantage is isolation: you don’t need to pollute your host OS with database binaries, manage background system services, or clean up leftover files when you’re done. You can spin up a pristine instance, run your experiments, and tear it down in seconds.</p><h4>Stateful Data</h4><p>The most interesting architectural challenge with running databases in containers is state management. Containers are designed to be stateless and ephemeral(short-lived). By default, any data written inside a running container lives in a temporary writable layer that disappears when the container is deleted or recreated.</p><p>Databases, on the other hand, are inherently stateful — their entire job is durability and preserving data across restarts and crashes. To bridge this gap, container environments decouple the database engine process from the underlying storage by using persistent volumes. By mounting an external storage volume or directory to the container’s data path, the database files live safely on persistent host or network storage. This allows you to destroy, recreate, or upgrade the container whenever you want without losing any data.</p><h4>Running PostgreSQL in a Container</h4><p>For this walk-through, I am using the <a href="https://podman.io/">Podman container engine </a>(an open-source project created and maintained by Red Hat). If you prefer Docker, the commands below are practically identical.<br> <br>Open a terminal in Linux and run the following command (make sure your machine has internet access to pull the image).</p><pre>podman run --name pg-playground \<br>-e POSTGRES_PASSWORD=Password12345 \<br>-p 5432:5432 \<br>-v pgdata:/var/lib/postgresql/data \<br>-d docker.io/library/postgres:16 </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*bJZSedzcq1jvo8nNwJCb5g.png" /></figure><p><em>Note: if you happen to be using docker for this, just replace the podman command with the word “docker” and you’re all set.</em></p><p>Here is a breakdown of what the above podman parameters are doing:<br><strong>--name pg-playground</strong>: Names the container so you don&#39;t have to use a container ID.<br><strong>-e POSTGRES_PASSWORD=Password12345</strong>: Sets the password for the default postgres superuser account.<br><strong>-p 5432:5432</strong>: Maps host port 5432 (left of the colon) to PostgreSQL’s default port 5432 inside the container (right of the colon). If your host machine already uses 5432, you can map a different host port (e.g., -p 5433:5432). <br><strong>-v pgdata:/var/lib/postgresql/data</strong>: Creates a named storage volume called pgdata on your host and mounts it to PostgreSQL’s internal data directory, ensuring all database files and transaction logs persist even if the container is stopped or deleted.<br><strong>-d</strong>: Runs the container in the background. In this case the image for PostgreSQL is being pulled from the repository at docker.io. postgres:16: Specifies the PostgreSQL 16 image.</p><p>Note: while I do specify the named storage volume for the PostgreSQL files, it is not required for this exercise. Skipping the -v flag makes the instance completely disposable, which is fine for quick testing, but named volumes are standard practice whenever you want data to survive container upgrades or teardowns.</p><h4>Connect to the PostgreSQL Container</h4><p>Now that we have PostgreSQL up and running in a container, we need to connect to it. We have several options, a couple of which I am going to cover today.</p><p><strong>Option 1: Use podman exec to run psql inside the container</strong><br>The container image already has the psql client installed, so you don’t even need database tools on your host machine. You can jump directly into an interactive session via Podman:</p><pre>podman exec -it pg-playground psql -U postgres</pre><p>This drops you into an interactive psql prompt (exact same concept as using sqlcmd in the SQL Server world). From here, you can run queries directly against the engine. For example, let’s check the database version by calling the version() function (the PostgreSQL equivalent of SQL Server’s @@VERSION):</p><pre> SELECT version();</pre><p>Here we can see the output from the call to my container instance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*NJlfs6sEmPUMQZYvQMwc7g.png" /></figure><p><strong>Option 2: Install psql locally on your host OS</strong><br>If you prefer running client tools directly from your host terminal, you can install the PostgreSQL client package (package manager commands will vary depending on your Linux distribution, such as Debian/Ubuntu vs. RHEL/Fedora):</p><pre>sudo apt update &amp;&amp; sudo apt install -y postgresql-client</pre><p>Then you can connect directly via psql. I am omitting the password parameter for the call, so PostgreSQL will prompt me to enter it as it connects:</p><pre>psql -h localhost -p 5432 -U postgres -d postgres</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*uf7tnYLFZHB1QO5LtO_4fQ.png" /></figure><p>Of course, you can also connect via GUI tools like pgAdmin or DBeaver (my favorite) — and I’ll cover these in an upcoming post.</p><h4>Creating Your First Database</h4><p>Let’s create a database to test with. In honor of our SQL Server background, we’ll name it after Microsoft’s sample <a href="https://learn.microsoft.com/en-us/sql/samples/adventureworks-install-configure?view=sql-server-ver17&amp;tabs=ssms">AdventureWorks database:</a></p><pre>CREATE DATABASE adventureworks;</pre><p><em>Notes:<br>1. Object names in PostgreSQL are automatically converted to lowercase internally, unless they are enclosed in double quotes (“AdventureWorks”). If you type AdventureWorks without double quotes, the engine will still name it adventureworks.<br> 2. The semicolon (;) is required to terminate SQL statements in psql. While T-SQL often lets you get away without them, the psql client buffers multi-line input and will keep waiting until it encounters a semicolon (or \g) before sending your query to the server.</em></p><h4>Switching Database Context</h4><p>Now that the database is created, we need to switch our context to it. In SQL Server, you would execute the USE command within your existing session. In PostgreSQL, there is no USE statement because a backend connection is strictly tied to a single database.<br> <br> To switch databases in psql, use the <strong>\c</strong> meta-command (which drops your current connection and reconnects you to the specified database):</p><pre># Establish new connection to adventureworks db<br>\c adventureworks</pre><p>You will see: You are now connected to database &quot;adventureworks&quot; as user &quot;postgres&quot;. Your prompt will change to adventureworks=#.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*0hLrBGHTwo8hUQCdWurrJg.png" /></figure><h4>Cleaning Up The Playground</h4><p>One of the best features of containerized development is leaving zero footprint on your machine when you’re done. Here is how to tear down the environment:<br> <br> First, exit the psql prompt:</p><pre># Exit psql <br>\q</pre><p>Next, stop the running container and remove it:</p><pre># Stop the container<br>podman stop pg-playground<br><br># Remove the container<br>podman rm pg-playground</pre><p>Finally, let’s clean up the image and storage volume from your disk. This removes the cached PostgreSQL container image and permanently deletes the persistent data volume:</p><pre># Remove the downloaded image from cache<br>podman rmi docker.io/library/postgres:16<br><br>#Remove the persistent volume<br>podman volume rm pgdata</pre><h4>Wrapping Up</h4><p>And that’s it — your environment is back where we started. In under ten minutes, we spun up a modern PostgreSQL 16 engine, walked through a handful of architectural differences from SQL Server — from session-level database binding to volume persistence — and tore the entire stack down. This gives you a playground to experiment with PostgreSQL internals before we move into managed cloud engines like Cloud SQL and AlloyDB.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bece5d2676d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/running-postgresql-in-a-container-7bece5d2676d">Running PostgreSQL in a Container</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PostgreSQL for the SQL Server Pro]]></title>
            <link>https://medium.com/google-cloud/postgresql-for-the-sql-server-pro-b7c62f81a8d6?source=rss-2b333608d626------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7c62f81a8d6</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[microsoft-sql-server]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Tim Chapman]]></dc:creator>
            <pubDate>Fri, 14 Aug 2026 11:11:43 GMT</pubDate>
            <atom:updated>2026-08-14T11:11:43.646Z</atom:updated>
            <content:encoded><![CDATA[<h3>PostgreSQL for the SQL Server Pro</h3><p>Series Introduction!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CN0-57TmtksYDZ9i2PawZQ.png" /><figcaption>Lets add PostgreSQL to your databases tool belt.</figcaption></figure><p>The odds are pretty good that if you’re reading this, you have done a fair amount of work with Microsoft’s SQL Server database engine in your career. You likely know a decent amount about how the engine works, you know how to read execution plans, and you’ve developed some instincts for how queries, memory, and transactions behave under load.</p><p>I spent 15 years as an engineer at Microsoft, working deeply with SQL Server with some of the largest customers in the world. I worked with them to make sure their SQL Server landscape was reliable, performant (probably not a word, but I still love it), and delivered a lot of SQL Server training. The last 4–5 years at Microsoft, I spent working primarily with PostgreSQL and customers who were beginning to use Azure Database for PostgreSQL. I even developed all of the internal PostgreSQL training at Microsoft.</p><p>There were a couple of reasons I shifted from working exclusively with SQL Server and started to focus on PostgreSQL more. First, it was a new challenge and I loved that. I started to see Azure Database for PostgreSQL customers have questions about the product and I wanted to learn the tech so I could help them. Its like a new toy to play with to me. Second, and probably more importantly, PostgreSQL is the most commonly used database according to <a href="https://survey.stackoverflow.co/2025/technology#most-popular-technologies-database-database-prof">Stack Overflow’s developer survey.</a> That&#39;s a big deal — more and more customers are adopting it, so having these PostgreSQL tools in your tool belt will only help you long-term.</p><p>Of the many PostgreSQL customers I worked with while at Microsoft, almost all were well versed with SQL Server. PostgreSQL was completely new to them. Often this was a mandate from a CxO to introduce the Open-Source database to eventually migrate from SQL Server (the primary job I do today at Google). I watched a lot of smart SQL Server DBAs, architects, and developers have their eyes glaze over when they encountered PostgreSQL for the first time.</p><p>The immediate reaction is usually frustration or feeling like a beginner all over again (which is exactly how I felt when I started). When you’ve lived in SQL Server for years, logging into PostgreSQL for the first time feels like walking into someone else’s kitchen. You know how to cook, but you can’t find the knives, the stove works differently, and there’s no SQL Server Agent or DMVs in sight. You suddenly feel like a junior DBA again, which is a wild feeling when you’ve been managing databases for a long time.</p><p>The cool thing is - you don’t need to start from scratch. In fact, a large percentage of what you know about SQL Server translates itself very well to PostgreSQL. SQL Server is a database engine. PostgreSQL is a database engine. Lots of differences, but lots of similarities too.</p><p>You already understand relational theory. You know how write-ahead logging works, you understand locking and concurrency, you know how indexes work, and you know why memory allocation matters. The fundamental database principles haven’t changed — PostgreSQL just approaches those same core problems with a different architecture and design philosophy.</p><p>So that is what I want to accomplish with this series - I want to help you leverage your SQL Server knowledge and translate it to PostgreSQL. Selfishly, I want to get back into blogging again and nerd-out on some of the concepts. Whenever we tackle a PostgreSQL topic, we’ll use what you already know in SQL Server as our mental anchor, look at how PostgreSQL approaches the same challenge under the hood, and point out the real-world gotchas along the way.</p><p>So, let’s get to it. My first post (probably posted around the same time as this one) will show you spin up running PostgreSQL in a container. (We will be using a fair amount of Linux during this series, which will also be a great time).</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7c62f81a8d6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/postgresql-for-the-sql-server-pro-b7c62f81a8d6">PostgreSQL for the SQL Server Pro</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>