<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Blogs on Justin Jaffray</title>
    <link>https://justinjaffray.com/blog/</link>
    <description>Recent content in Blogs on Justin Jaffray</description>
    <generator>Hugo -- gohugo.io</generator>
    <lastBuildDate>Thu, 26 Jan 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://justinjaffray.com/blog/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>A Charming Algorithm for Count-Distinct</title>
      <link>https://justinjaffray.com/a-charming-algorithm-for-count-distinct/</link>
      <pubDate>Thu, 26 Jan 2023 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/a-charming-algorithm-for-count-distinct/</guid>
      <description>I recently came across a paper called Distinct Elements in Streams: An Algorithm for the (Text) Book by Chakraborty, Vinodchandran, and Meel.
The usage of the phrase &amp;ldquo;from the book&amp;rdquo; is of course a reference to Erdős, who often referred to a &amp;ldquo;book&amp;rdquo; within which God kept the best proofs of any given theorem. Thus, for something to be &amp;ldquo;from the book&amp;rdquo; is for it to be particularly elegant. I have to say, I agree with their assessment.</description>
    </item>
    
    
    
    <item>
      <title>Functional Dependencies and Orders</title>
      <link>https://justinjaffray.com/functional-dependencies-and-orders/</link>
      <pubDate>Sun, 25 Dec 2022 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/functional-dependencies-and-orders/</guid>
      <description>Say you&amp;rsquo;re a query optimizer. Is the following transformation &amp;ldquo;valid?&amp;rdquo;
select * from t where x &amp;gt; 5 =&amp;gt; select * from t where false Well&amp;hellip;I doubt it. The first version permits strictly more rows than the second.
But, what if I told you that we recently collected statistics on our data, and found that no more than 0.01% of our data has a value of x that&amp;rsquo;s larger than 5?</description>
    </item>
    
    
    
    <item>
      <title>JOIN: The Ultimate Projection</title>
      <link>https://justinjaffray.com/join-the-ultimate-projection/</link>
      <pubDate>Mon, 13 Jun 2022 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/join-the-ultimate-projection/</guid>
      <description>Or: the core idea of how database query planners decorrelate subqueries.
Joins In a relational database, to compute the join of \(R\) and \(S\) on \(p\), for each row \(r\) in \(R\), find all the rows \(s\) in \(S\) where \(p(r, s)\) is true, and emit the concatenation of \(r\) and \(s\). Readers of this blog might note this is a different definition than we&amp;rsquo;ve used in the past, but this one is well-suited to the way we&amp;rsquo;ll be using joins today.</description>
    </item>
    
    
    
    <item>
      <title>A Gentle(-ish) Introduction to Worst-Case Optimal Joins</title>
      <link>https://justinjaffray.com/a-gentle-ish-introduction-to-worst-case-optimal-joins/</link>
      <pubDate>Mon, 30 May 2022 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/a-gentle-ish-introduction-to-worst-case-optimal-joins/</guid>
      <description>If you&amp;rsquo;ve been following databases in the past couple years, you&amp;rsquo;ve probably encountered the term &amp;ldquo;worst-case optimal joins.&amp;rdquo; These are supposedly a big deal, since joins have been studied for a long time, and the prospect of a big shift in the way they&amp;rsquo;re thought about is very exciting to a lot of people.
The literature around them, however, is primiarly aimed at theorists. This post is as gentle and bottom-up as I can manage of an introduction to the main ideas behind them.</description>
    </item>
    
    
    
    <item>
      <title>Durability and Redo Logging</title>
      <link>https://justinjaffray.com/durability-and-redo-logging/</link>
      <pubDate>Mon, 24 Jan 2022 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/durability-and-redo-logging/</guid>
      <description>The most fundamental property a database can provide is durability. That is, once I’ve told you that your write has been accepted, if a mouse chews through the power cord for the server rack, the write will not be lost.
This obviously is only possible to a degree. If someone goes into your SSD with a magnetized needle and a steady hand and tweaks their bank balance, then (short of replication) the best you can probably do is detect that it&amp;rsquo;s been changed via a checksum, unless, of course, they had the foresight to update that as well.</description>
    </item>
    
    
    
    <item>
      <title>Compaction</title>
      <link>https://justinjaffray.com/compaction/</link>
      <pubDate>Wed, 26 May 2021 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/compaction/</guid>
      <description>You hear the word “log” a lot when talking about databases. This is because databases are fundamentally comprised of sin.
(Shared mutable state.)
Logs are natural in a setting where you want to be principled about your treatment of mutation because one way to think about mutation is how a variable starts from an initial value and undergoes several “transformations.”
This sequence of operations:
let x = 1; x = x + 3; let y = 7; x = x * 2; can be written to a log as a history of what operations were performed:</description>
    </item>
    
    
    
    <item>
      <title>Query Engines: Push vs. Pull</title>
      <link>https://justinjaffray.com/query-engines-push-vs.-pull/</link>
      <pubDate>Mon, 26 Apr 2021 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/query-engines-push-vs.-pull/</guid>
      <description>People talk a lot about &amp;ldquo;pull&amp;rdquo; vs. &amp;ldquo;push&amp;rdquo; based query engines, and it&amp;rsquo;s pretty obvious what that means colloquially, but some of the details can be a bit hard to figure out.
Important people clearly have thought hard about this distinction, judging by this paragraph from Snowflake&amp;rsquo;s Sigmod paper:
 Push-based execution refers to the fact that relational operators push their results to their downstream operators, rather than waiting for these operators to pull data (classic Volcano-style model).</description>
    </item>
    
    
    
    <item>
      <title>Deduplicating Decklists</title>
      <link>https://justinjaffray.com/deduplicating-decklists/</link>
      <pubDate>Thu, 17 Sep 2020 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/deduplicating-decklists/</guid>
      <description>This is not going to be my normal kind of post, it&amp;rsquo;s not very focused, and going to be a bit rambley, as I talk about a problem I thought about one day.
Magic: The Gathering is a card game where players construct decks, typically of 60 cards plus a 15 card sideboard, for 75 cards total.
Periodically, the company that makes the game, Wizards of the Coast (WotC) publishes a list of decks that did well recently.</description>
    </item>
    
    
    
    <item>
      <title>Branch and Bound</title>
      <link>https://justinjaffray.com/branch-and-bound/</link>
      <pubDate>Thu, 11 Jun 2020 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/branch-and-bound/</guid>
      <description>Sometimes I write posts because I think I have a fresh perspective on something, and sometimes I write posts because for whatever reason I think every explanation of a particular concept that I&amp;rsquo;ve seen is bad. This is the latter! This post is about a lovely technique for discrete optimization called Branch and Bound.
Optimization problems can generally be viewed as a search for an object with the lowest &amp;ldquo;cost.&amp;rdquo; For instance, given an instance of the Traveling Salesman Problem (TSP), the &amp;ldquo;objects&amp;rdquo; we&amp;rsquo;re searching for are &amp;ldquo;tours,&amp;rdquo; or a cycle in the graph that visits every &amp;ldquo;city&amp;rdquo; exactly once.</description>
    </item>
    
    
    
    <item>
      <title>Understanding Cost Models</title>
      <link>https://justinjaffray.com/understanding-cost-models/</link>
      <pubDate>Mon, 11 May 2020 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/understanding-cost-models/</guid>
      <description>The dominant way modern query planners decide what algorithms to use for a given query is via a cost model. Effectively, they enumerate the set of possible plans for a query, and then run their cost model over each one, eventually returning whichever one had the cheapest cost according to the model.
Analytic queries can become complex, horrifically so, in fact, and assessing their costs follows suit. To alleviate this somewhat, we&amp;rsquo;re going to explore some tools we can use to attempt to travel up the ladder of abstraction for query planners.</description>
    </item>
    
    
    
    <item>
      <title>Timely Dataflow and Total Order</title>
      <link>https://justinjaffray.com/timely-dataflow-and-total-order/</link>
      <pubDate>Mon, 06 Apr 2020 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/timely-dataflow-and-total-order/</guid>
      <description>In anticipation of starting at Materialize, I&amp;rsquo;ve been reading through some of the fundamental literature that the product is built on. The first paper I&amp;rsquo;ve read through is Naiad: A Timely Dataflow System.
I enlisted the help of friends Forte Shinko and Ilia Chtcherbakov to help me work through it, and we ended up finding an interesting question that I&amp;rsquo;m not aware of a proof online for, so I&amp;rsquo;m going to share it today.</description>
    </item>
    
    
    
    <item>
      <title>What is a Query Optimizer for?</title>
      <link>https://justinjaffray.com/what-is-a-query-optimizer-for/</link>
      <pubDate>Tue, 11 Feb 2020 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/what-is-a-query-optimizer-for/</guid>
      <description>You could be forgiven for thinking that a &amp;ldquo;query optimizer&amp;rdquo; is a component of a database that takes a query plan and makes it better, hence, the typical programmer definition of &amp;ldquo;optimize.&amp;rdquo; This is not really how the term is used in practice, and &amp;ldquo;query optimizer&amp;rdquo; is really pretty synonomous with &amp;ldquo;query planner.&amp;rdquo; I think &amp;ldquo;query planner&amp;rdquo; is a better term so I&amp;rsquo;m going to use that.
SQL is fundamentally designed such that users express what data they want rather than an algorithm for retrieving it, and this property gives us I think, the most basic definition of a query planner&amp;rsquo;s job:</description>
    </item>
    
    
    
    <item>
      <title>Join Ordering: The IKKBZ Algorithm</title>
      <link>https://justinjaffray.com/join-ordering-the-ikkbz-algorithm/</link>
      <pubDate>Thu, 05 Sep 2019 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/join-ordering-the-ikkbz-algorithm/</guid>
      <description>This post was originally posted on the Cockroach Labs Blog
Even in the 80’s, before Facebook knew everything there was to know about us, we as an industry had vast reams of data we needed to be able to answer questions about. To deal with this, data analysts were starting to flex their JOIN muscles in increasingly creative ways. But back in that day and age, we had neither machine learning nor rooms full of underpaid Excel-proficient interns to save us from problems we didn’t understand; we were on our own.</description>
    </item>
    
    
    
    <item>
      <title>An Introduction to Join Ordering</title>
      <link>https://justinjaffray.com/an-introduction-to-join-ordering/</link>
      <pubDate>Tue, 23 Oct 2018 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/an-introduction-to-join-ordering/</guid>
      <description>This post was originally posted on the Cockroach Labs Blog
The development of the relational model heralded a big step forward for the world of databases. The introduction of SQL meant that analysts could construct a new report without having to interact with those eggheads in engineering, but more importantly, the existence of complex join queries meant that theoreticians had an interesting new NP-complete problem to fawn over for the next five decades.</description>
    </item>
    
    
    
    <item>
      <title>Why Consensus?</title>
      <link>https://justinjaffray.com/why-consensus/</link>
      <pubDate>Tue, 15 May 2018 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/why-consensus/</guid>
      <description>Depending on which computer scientists and greek lawmakers you listen to, Paxos could either be taught to a 3-year old, or requires a team of PhDs &amp;ldquo;almost a year&amp;rdquo; to fully grasp. I think the discrepancy here comes from a poorly motivated setting. I couldn’t have provided a coherent explanation of what consensus was a year ago, but in the time since then I’ve slowly pieced together an understanding of it thanks to coworkers who put up with my questions.</description>
    </item>
    
    
    
    <item>
      <title>A Proof of Correctness for CASPaxos</title>
      <link>https://justinjaffray.com/a-proof-of-correctness-for-caspaxos/</link>
      <pubDate>Tue, 10 Apr 2018 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/a-proof-of-correctness-for-caspaxos/</guid>
      <description>This post was co-written with Ilia Chtcherbakov.
CASPaxos is a recent and interesting consensus algorithm invented by Denis Rystsov.
The paper describing CASPaxos provides a proof of correctness in its appendix, provided here is an alternative proof.
First, let&amp;rsquo;s review the protocol. There are several participants.
Clients A client submits a transformation function to a proposer.
The proposer might reply with a success message consisting of the output of the function applied to the previous value of the register, along with the claim that the value returned was placed into the register.</description>
    </item>
    
    
    
    <item>
      <title>What Does Write Skew Look Like?</title>
      <link>https://justinjaffray.com/what-does-write-skew-look-like/</link>
      <pubDate>Wed, 28 Mar 2018 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/what-does-write-skew-look-like/</guid>
      <description>This post is about gaining intuition for Write Skew, and, by extension, Snapshot Isolation. Snapshot Isolation is billed as a transaction isolation level that offers a good mix between performance and correctness, but the precise meaning of &amp;ldquo;correctness&amp;rdquo; here is often vague. In this post I want to break down and capture exactly when the thing called &amp;ldquo;write skew&amp;rdquo; can happen.
A quick primer on transactions The unit of execution in a database is a transaction.</description>
    </item>
    
    
    
    <item>
      <title>Reflections on Stacking Stacks</title>
      <link>https://justinjaffray.com/reflections-on-stacking-stacks/</link>
      <pubDate>Tue, 13 Mar 2018 00:00:00 +0000</pubDate>
      
      <guid>https://justinjaffray.com/reflections-on-stacking-stacks/</guid>
      <description>I&amp;rsquo;ve been on both ends of several variations of the following conversation:
FRIEND:
 Check out this algorithm. It checks that a string of parentheses, brackets, and braces is balanced properly. It goes like this:
  You iterate through the string while keeping a stack. When you see an opening paren/bracket/brace you push it on. When you see a closing paren, if it&amp;rsquo;s the same kind as the one on top of the stack, you pop the stack.</description>
    </item>
    
    
    
    <item>
      <title>Making a PICO-8 TAS</title>
      <link>https://justinjaffray.com/making-a-pico-8-tas/</link>
      <pubDate>Fri, 09 Sep 2016 00:06:15 -0400</pubDate>
      
      <guid>https://justinjaffray.com/making-a-pico-8-tas/</guid>
      <description>Speedrunners turn the process of beating a single-player video game into a competitive activity, trying to finish games as quickly as humanly possible. This has become increasingly mainstream (though still niche) in the past few years with the rise in popularity of events like Games Done Quick. However, there&amp;rsquo;s another, smaller community interested in beating games quickly but from a different perspective: how quickly can a game be beaten if humans are taken out of the equation?</description>
    </item>
    
    
  </channel>
</rss>