<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://brokenco.de//feed/by_tag/dataeng.xml" rel="self" type="application/atom+xml" /><link href="https://brokenco.de//" rel="alternate" type="text/html" /><updated>2026-10-31T17:58:32+00:00</updated><id>https://brokenco.de//feed/by_tag/dataeng.xml</id><title type="html">rtyler</title><subtitle>a moderately technical blog</subtitle><author><name>R. Tyler Croy</name></author><entry><title type="html">Crashing the index with PostgreSQL custom types</title><link href="https://brokenco.de//2026/08/14/custom-types-index.html" rel="alternate" type="text/html" title="Crashing the index with PostgreSQL custom types" /><published>2026-08-14T00:00:00+00:00</published><updated>2026-08-14T00:00:00+00:00</updated><id>https://brokenco.de//2026/08/14/custom-types-index</id><content type="html" xml:base="https://brokenco.de//2026/08/14/custom-types-index.html"><![CDATA[<p>My current work project is one of the first Aurora/PostgreSQL deployments and
already the <strong>largest</strong>. Success brings <em>scaling challenges</em> and the types of
things seasoned operators classify as “good problems to have.” Compared to
previous scaling work around <a href="https://delta.io">Delta Lake</a> the knobs and ways
in which online relational databases scale is a muscle that has atrophied in
the past decade. The relational database landscape is also quite different
especially with <a href="https://aws.amazon.com/video/watch/f2a0fcbccb8/">Amazon Aurora which is quite well
designed</a>in the past decade.
The relational database landscape is also quite different especially with
<a href="https://aws.amazon.com/video/watch/f2a0fcbccb8/">Amazon Aurora which is quite well
designed</a>.</p>

<p>At some point it doesn’t matter how “well architected” the underlying database engine was, the laws of physics still apply. The speed of light between CPU cores, storage, and memory still imposes limitations. Similar to my work
related to <a href="/2026/02/13/screaming-in-the-cloud.html">Engineering around Extreme S3
scale</a>, the difference between systems
which handle hundreds of millions of <em>something</em> and hundreds of <strong>billions</strong>
of something is substantial.</p>

<p>My original database design relied upon <a href="https://www.postgresql.org/docs/current/sql-createtype.html">Custom
types</a>, which I
really enjoy using for easily mapping complex data types into PostgreSQL.
Similar to a <code class="language-plaintext highlighter-rouge">struct</code> in Rust, at it’s most simple a custom type is a
collection of associated fields:</p>

<div class="language-rust highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">struct</span> <span class="n">Coordinate</span> <span class="p">{</span>
    <span class="n">brand</span><span class="p">:</span> <span class="n">Brand</span><span class="p">,</span>
    <span class="n">doc_id</span><span class="p">:</span> <span class="nb">u64</span><span class="p">,</span>
    <span class="n">page</span><span class="p">:</span> <span class="nb">Option</span><span class="o">&lt;</span><span class="nb">u32</span><span class="o">&gt;</span><span class="p">,</span>
<span class="p">};</span>
</code></pre></div></div>

<p>Can easily map into the database with:</p>

<div class="language-sql highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">CREATE</span> <span class="k">TYPE</span> <span class="n">coordinate</span> <span class="k">AS</span> <span class="p">(</span><span class="n">brand</span> <span class="n">BRAND</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> <span class="n">doc_id</span> <span class="nb">BIGINT</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> <span class="n">page</span><span class="p">:</span> <span class="nb">INTEGER</span><span class="p">);</span>
</code></pre></div></div>
<p>The utility of custom types is so <em>alluring</em> for modeling richer data in at the
database level because so much of our mental models for systems are driven by
data encapsulation. I see similar design patterns from my colleagues when working with Delta Lake tables. A preference for creating columns of deeply nested structs, despite my protestations around flattening the into wider table schemas with more columns.</p>

<p>The biggest performance downside with custom types that I observed was when
using custom types in <strong>indexes</strong> but the issue was obscured by Aurora’s
exceptional performance until we crossed into the <em>billions</em> scale.</p>

<p>For the PostgreSQL engine version we were running, custom types in indexes would only be used correctly if the full type was present in the query. Using the example above this meant that a query would <strong>not use the index correctly</strong> when querying on <code class="language-plaintext highlighter-rouge">doc_id</code> alone! Instead the query was required to construct a type inline, e.g.:</p>

<div class="language-sql highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="n">some_table</span> 
    <span class="k">WHERE</span> <span class="k">c</span> <span class="o">=</span> <span class="p">(</span><span class="s1">'scribd'</span><span class="p">,</span> <span class="mi">123</span><span class="p">,</span> <span class="k">NULL</span><span class="p">)::</span><span class="n">COORDINATE</span>

</code></pre></div></div>

<p>The inefficiencies of queries with a partial custom type predicate wasn’t
noticed until queries in hitting billion row tables started to slow down. Those
production query plans made it fairly obvious that the index wasn’t being used,
but it was not clear to me <em>why</em> until after we really considered the offending query plans.</p>

<p><strong>Storage</strong> of the custom type was also not something I considered until after
the billions scale where the indexes and table sizes ballooned. The <a href="https://www.postgresql.org/docs/current/datatype-enum.html">enumerated
type</a> occupies four
bytes on disk. Combined with the other two entries in the type each row
required 16 bytes of storage. With smaller scale data that’s kind of a “who
cares” amount of data but 10 billion rows that equates to around 149GiB to
store nothing but this one custom type in the table.</p>

<hr />

<p>The solution we ended up with to resolve the inefficiencies of the custom type
for query and storage performance was to switch towards a bit-masked 64-bit
integer with the custom type’s properties encoded within.</p>

<p>My colleague experimented with using a binary encoded field which had similar
benefits over a custom type. Ultimately the bitmask approach allowed us to
halve the storage requirements and improved query performance since the index
moved from a hash index to a <a href="https://www.postgresql.org/docs/current/indexes-types.html">b-tree
index</a> for
operations on that column.</p>

<p><strong>Billions</strong> is such an astronomically large number that I often explain that
the “physics of billions” is so fundamentally different that it’s like going
from Newtonian to Quantum physics: the old rules no longer apply. In our online
data system, we have tables that vary from hundreds of millions of rows, to
tens of billions of rows, and our modelling has to account for <em>both</em> which has
been an exciting challenge.</p>

<center><iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/XCv9Tviftgo?si=BzXciAynsuGwsshX" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen=""></iframe></center>

<p>The system would not have gotten this far without some of the superpowers that
PostgreSQL has to offer. Originally we deployed to PostgreSQL 17 but after
watching the above session we were convinced to upgrade to PostgreSQL 18 and
reaped the additional performance rewards offered by the upgrade.</p>

<p>PostgreSQL by default is quite fast. Aurora/PostgreSQL by default is
exceptionally fast. As a data system grows the “nice problems to have” start
popping up and query plans, APM traces, and all other sorts of telemetry become
crucial to understanding how and where to start improving performance.</p>

<p>I would not recommend avoiding custom types in PostgreSQL, there is a time and
a place for them, and we’re still using them quite heavily, just not as indexed
columns!</p>]]></content><author><name>R. Tyler Croy</name></author><category term="postgresql" /><category term="data" /><category term="dataeng" /><summary type="html"><![CDATA[My current work project is one of the first Aurora/PostgreSQL deployments and already the largest. Success brings scaling challenges and the types of things seasoned operators classify as “good problems to have.” Compared to previous scaling work around Delta Lake the knobs and ways in which online relational databases scale is a muscle that has atrophied in the past decade. The relational database landscape is also quite different especially with Amazon Aurora which is quite well designedin the past decade. The relational database landscape is also quite different especially with Amazon Aurora which is quite well designed.]]></summary></entry><entry><title type="html">Elephant in the room</title><link href="https://brokenco.de//2026/02/21/elephant-in-the-room.html" rel="alternate" type="text/html" title="Elephant in the room" /><published>2026-02-21T00:00:00+00:00</published><updated>2026-02-21T00:00:00+00:00</updated><id>https://brokenco.de//2026/02/21/elephant-in-the-room</id><content type="html" xml:base="https://brokenco.de//2026/02/21/elephant-in-the-room.html"><![CDATA[<p>just use postgres</p>]]></content><author><name>R. Tyler Croy</name></author><category term="software" /><category term="dataeng" /><category term="postgresql" /><summary type="html"><![CDATA[just use postgres]]></summary></entry><entry><title type="html">On Data Engineering Central</title><link href="https://brokenco.de//2026/02/04/data-engineering-central.html" rel="alternate" type="text/html" title="On Data Engineering Central" /><published>2026-02-04T00:00:00+00:00</published><updated>2026-02-04T00:00:00+00:00</updated><id>https://brokenco.de//2026/02/04/data-engineering-central</id><content type="html" xml:base="https://brokenco.de//2026/02/04/data-engineering-central.html"><![CDATA[<p>I was lucky enough to <a href="https://dataengineeringcentral.substack.com/p/the-lakehouse-architecture-multimodal">record a podcast
episode</a>
with Daniel Beach of Data Engineering Central. Daniel and I have known each
other for a couple years sharing notes and ideas on the state of the ecosystem,
where it falls down, and where things are getting interesting.</p>

<p>In my opinion <a href="https://dataengineeringcentral.substack.com">Data Engineering
Central</a> has been one of the most
useful broad-ranged surveys of the ecosystem, curated by one crazy
mid-westerner: Daniel. He pulls no punches and while we share criticisms of AI
in the industry and commercial tools, Daniel’s honesty also has put some of my
work on blast, such as <a href="https://dataengineeringcentral.substack.com/p/_internaldeltaprotocolerror">this
post</a>
about some terrible user-experience and lopsided Delta Lake support in
<a href="https://github.com/delta-io/deltars">delta-rs</a>.</p>

<p>In his post Daniel highlights some of the topics we got into during our time chatting:</p>

<blockquote>
  <ul>
    <li>What the Lakehouse architecture gets right—and where it still falls short</li>
    <li>Why multimodal data (text, images, audio, video, embeddings) changes everything</li>
    <li>How open table formats like Delta Lake fit into the next generation of data platforms</li>
    <li>The growing gap between data tooling hype and day-to-day data engineering reality</li>
    <li>What skills and architectural thinking will matter most for data engineers over the next decade</li>
  </ul>
</blockquote>

<center><iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/WLlko-liHMg?si=9aGp1v-6nm2kbya0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen=""></iframe></center>

<p>I encourage you to <a href="https://dataengineeringcentral.substack.com/">subscribe</a> to
his newsletter or if that’s not your jam, you can <a href="https://dataengineeringcentral.substack.com/feed">subscribe to the RSS
feed</a> too.</p>]]></content><author><name>R. Tyler Croy</name></author><category term="software" /><category term="dataeng" /><category term="buoyantdata" /><category term="databricks" /><category term="podcast" /><summary type="html"><![CDATA[I was lucky enough to record a podcast episode with Daniel Beach of Data Engineering Central. Daniel and I have known each other for a couple years sharing notes and ideas on the state of the ecosystem, where it falls down, and where things are getting interesting.]]></summary></entry><entry><title type="html">The last data file format</title><link href="https://brokenco.de//2025/07/16/no-way-parquet.html" rel="alternate" type="text/html" title="The last data file format" /><published>2025-07-16T00:00:00+00:00</published><updated>2025-07-16T00:00:00+00:00</updated><id>https://brokenco.de//2025/07/16/no-way-parquet</id><content type="html" xml:base="https://brokenco.de//2025/07/16/no-way-parquet.html"><![CDATA[<p>The layers of abstraction in most technology stacks has gotten incredibly deep
over the last decade. At some point way down there in the depths of <em>most</em> data
applications somebody <em>somewhere</em> has to actually read or write bytes to
storage. The flexibility of <a href="https://parquet.apache.org">Apache Parquet</a> has me
increasingly convinced that it just might be the <strong>last data file format I will
need</strong>.</p>

<p>In my <a href="/2025/06/24/low-latency-parquet.html">previous post</a> on the subject I
wrote about the file format’s novelty for semi-random data access <em>inside</em> of a
<code class="language-plaintext highlighter-rouge">.parquet</code> file. I’m certainly wandering off the beaten path with Apache
Parquet already. <em>Then</em> this blog post kind of blew my mind: <a href="https://datafusion.apache.org/blog/2025/07/14/user-defined-parquet-indexes/">Embedding
User-Defined Indexes in Apache Parquet
Files</a>.</p>

<blockquote>
  <p>However, Parquet is extensible with user-defined indexes: <strong>Parquet tolerates
unknown bytes within the file body</strong> and permits arbitrary key/value pairs in
its footer metadata. These two features enable embedding user-defined indexes
directly in the file—no extra files, no format forks, and no compatibility
breakage.</p>
</blockquote>

<p>Emphasis mine.</p>

<p>This is news to me.</p>

<p>And it is <em>absolutely wild</em>.</p>

<hr />

<p>The authors’ approach for embedding user-defined indexes in Apache Parquet
files is certainly novel and already worth a read.</p>

<p>But the fact that you can shove arbitrary blocks of bytes in the middle of the
otherwise columnar data format is incredible.</p>

<p>Modifications of Apache Parquet files still requires a rewrite of the
object which means <code class="language-plaintext highlighter-rouge">.parquet</code> is not a file format to be used for heavy data
modification workloads.</p>

<p>Use-cases with large amounts of metadata and binary data however would fit nicely
within this parquet + unknown bytes design. Parquet readers which are ignorant
to the purpose for these unknown byte blocks will completely ignore them.</p>

<p>Altogether this is a new super
power, and I am contemplating whether I can use it for good or evil..</p>]]></content><author><name>R. Tyler Croy</name></author><category term="rust" /><category term="parquet" /><category term="buoyantdata" /><category term="dataeng" /><summary type="html"><![CDATA[The layers of abstraction in most technology stacks has gotten incredibly deep over the last decade. At some point way down there in the depths of most data applications somebody somewhere has to actually read or write bytes to storage. The flexibility of Apache Parquet has me increasingly convinced that it just might be the last data file format I will need.]]></summary></entry><entry><title type="html">Local SQL querying in Jupyter Notebooks</title><link href="https://brokenco.de//2022/04/29/local-sql-with-jupyter.html" rel="alternate" type="text/html" title="Local SQL querying in Jupyter Notebooks" /><published>2022-04-29T00:00:00+00:00</published><updated>2022-04-29T00:00:00+00:00</updated><id>https://brokenco.de//2022/04/29/local-sql-with-jupyter</id><content type="html" xml:base="https://brokenco.de//2022/04/29/local-sql-with-jupyter.html"><![CDATA[<p>Designing, working with, or thinking about data consumes the vast majority of
my time these days, but almost all of that has been “in the cloud” rather than
locally. I recently watched <a href="https://www.youtube.com/watch?v=RqubKSF3wig">this talk about SQLite and
Go</a> which served as a good
reminder that I have a pretty powerful computer at my fingertips, and that
perhaps not all my workloads require a big <a href="https://spark.apache.org">Spark</a>
cluster in the sky. Shortly after watching that video I stumbled into a small
(200k rows) data set which I needed to run some queries against, and my first
attempt at auto-ingesting it into a <a href="https://delta.io">Delta table</a> in
Databricks failed, so I decided to launch a local <a href="https://jupyter.org/">Jupyter
notebook</a> and give it a try!</p>

<p>My originating data set was a comma-separated values file (CSV) so my first
intent was to just load it into SQLite using the <code class="language-plaintext highlighter-rouge">.mode csv</code> command in the
CLI, but I found that to be a bit restrictive. Notebooks have incredible
utility for incrementally working on data. Unfortunately Jupyter doesn’t have a
native SQL interface, instead everything has to run through Python. Through my
work with <a href="https://github.com/delta-io/delta-rs">delta-rs</a> I am somewhat
familar with <a href="https://pandas.pydata.org/">Pandas</a> for processing data in
Python, so my first attempts where using the Pandas data frame API to munge
through my data.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">pandas</span>

<span class="n">df</span> <span class="o">=</span> <span class="n">pandas</span><span class="p">.</span><span class="n">read_csv</span><span class="p">(</span><span class="s">'data/2021_05-2022_04.csv'</span><span class="p">)</span>
</code></pre></div></div>

<p>I could be dense, but I find SQL to be a pretty understandable tool in
comparison to data frames, so I needed to find some way to get the data into a
SQL interface. The solution that I ended up with was to create an in-memory
SQLite database and use Pandas to query it, which works <em>okay enough</em> to where
I continued working and didn’t bother thinking too much about how to optimize
the approach further:</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">sqlite3</span>
<span class="kn">import</span> <span class="nn">pandas</span>

<span class="c1"># Loading everything into a SQLite memory database because I hate data frames and SQL is nice
</span><span class="n">conn</span> <span class="o">=</span> <span class="n">sqlite3</span><span class="p">.</span><span class="n">connect</span><span class="p">(</span><span class="s">':memory:'</span><span class="p">)</span>
<span class="n">df</span> <span class="o">=</span> <span class="n">pandas</span><span class="p">.</span><span class="n">read_csv</span><span class="p">(</span><span class="s">'data/2021_05-2022_04.csv'</span><span class="p">)</span>
<span class="n">r</span> <span class="o">=</span> <span class="n">df</span><span class="p">.</span><span class="n">to_sql</span><span class="p">(</span><span class="s">'usage'</span><span class="p">,</span> <span class="n">conn</span><span class="p">,</span> <span class="n">if_exists</span><span class="o">=</span><span class="s">'replace'</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="c1"># useful little helper
</span><span class="n">sql</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">pandas</span><span class="p">.</span><span class="n">read_sql_query</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">conn</span><span class="p">)</span>


<span class="c1"># Show some sample data
</span><span class="n">sql</span><span class="p">(</span><span class="s">'SELECT * FROM usage LIMIT 3'</span><span class="p">)</span>
</code></pre></div></div>

<p>The benefit of this approach is that I can create additional tables in the
SQLite database with static data sets, or other CSVs. Since I’m also just doing
some simple ad-hoc analysis, I can skip writing anything to disk and keep
things snappy in memory.</p>

<p>I created the little <code class="language-plaintext highlighter-rouge">sql</code> lambda to make the notebook a bit more
understandable, and to get out of exposing the cursor or database connection to
every single cell, meaning that most of my cells in the notebook are simply
just <code class="language-plaintext highlighter-rouge">sql('SELECT * FROM foo')</code> statments with some documentation surrounding
them.</p>

<p>Fairly simple, easy enough to play with data quickly on my local machine
without invoking all the infinite cosmic powers the cloud provides!</p>]]></content><author><name>R. Tyler Croy</name></author><category term="dataeng" /><category term="databricks" /><summary type="html"><![CDATA[Designing, working with, or thinking about data consumes the vast majority of my time these days, but almost all of that has been “in the cloud” rather than locally. I recently watched this talk about SQLite and Go which served as a good reminder that I have a pretty powerful computer at my fingertips, and that perhaps not all my workloads require a big Spark cluster in the sky. Shortly after watching that video I stumbled into a small (200k rows) data set which I needed to run some queries against, and my first attempt at auto-ingesting it into a Delta table in Databricks failed, so I decided to launch a local Jupyter notebook and give it a try!]]></summary></entry></feed>