HN user

foldU

460 karma

https://justinjaffray.com/

https://buttondown.email/jaffray

Posts49
Comments28
View on HN
www.datadoghq.com 10mo ago

From hand-tuned Go to self-optimizing code: Building BitsEvolve

foldU
11pts0
buttondown.com 1y ago

How to Understand That Jepsen Report

foldU
4pts0
buttondown.com 1y ago

Automating the Blue Prince Parlor Puzzle

foldU
2pts0
buttondown.com 1y ago

Propositional Parlor Puzzle

foldU
27pts4
www.keithschwarz.com 1y ago

Darts, Dice, and Coins: Sampling from a Discrete Distribution (2011)

foldU
3pts0
buttondown.com 1y ago

It's Time to Stop Building KV Databases

foldU
65pts62
buttondown.com 1y ago

Thoughts on DuckDB's Grammar Patching Thing

foldU
34pts3
buttondown.com 1y ago

Fine, I'll Play With Skiplists

foldU
120pts15
buttondown.com 1y ago

Fine! I'll Play with Skiplists

foldU
2pts0
buttondown.com 1y ago

Integrity Constraints and the Relational Derivative

foldU
1pts0
buttondown.email 2y ago

TPC-See?

foldU
2pts0
justinjaffray.com 2y ago

A Charming Algorithm for Count-Distinct

foldU
24pts1
buttondown.email 2y ago

A Card Counting Trick

foldU
2pts0
buttondown.email 2y ago

My First Distributed System

foldU
2pts0
buttondown.email 2y ago

A Sniff Test for Some Query Optimizers

foldU
2pts0
buttondown.email 2y ago

The Little Planner Chapter 4: A Pushdown Party

foldU
1pts0
buttondown.email 2y ago

The Little Planner Chapter 4: A Pushdown Party

foldU
4pts0
buttondown.email 2y ago

SQL Scoping Is Surprisingly Subtle and Semantic

foldU
2pts0
buttondown.email 2y ago

SQL Scoping Is Surprisingly Subtle and Semantic

foldU
2pts0
buttondown.email 2y ago

SQL Scoping Is Surprisingly Subtle and Semantic

foldU
9pts0
buttondown.email 2y ago

The Case of a Curious SQL Query

foldU
5pts0
buttondown.email 2y ago

The Case of a Curious SQL Query

foldU
9pts0
buttondown.email 2y ago

Representing Columns in Query Optimizers

foldU
3pts0
buttondown.email 2y ago

Why Are Query Plans Trees?

foldU
1pts0
buttondown.email 2y ago

Internal Affairs

foldU
4pts1
buttondown.email 2y ago

The Halloween Problem

foldU
3pts0
justinjaffray.com 3y ago

Joins 13 Ways

foldU
531pts76
cs.stanford.edu 3y ago

The CVM Algorithm for Estimating Distinct Elements in Streams [pdf]

foldU
3pts1
justinjaffray.com 3y ago

A Charming Algorithm for Count-Distinct

foldU
2pts0
justinjaffray.com 3y ago

A Charming Algorithm for Count-Distinct

foldU
9pts2

The geometric representation of AM/GM is very cool, but the first animation seems wrong to me, it should be varying the value of `b`, not the location of the circle, for it to make sense, no?

This is correct, I appreciate you for putting it so coherently :). I think I didn’t make it clear enough in the piece that I’m coming from a stance of fast access being table stakes, and the question being about how that’s accomplished.

(author of OP) That post of yours was actually what got me tooling around with this stuff again :) it's a really excellent one

More deserves to be written on the ILP idea, I haven't actually tried to make it work but it seems to me like the only real direction to optimize ("optimize" used in the mathematical sense, rather than the programming sense) queries that you can't just exploit the principle of optimality on (see this earlier article I wrote [1] for a bit more exposition). I think maybe some of the egg [2] people have experimented with this.

Speaking from experience, there's lots of rewrites you'd want to do in a query optimizer that having access to efficient DAG-shaped query plans would make tenable, but as a specific example they are an important part of doing full subquery decorrelation [3].

[1] https://buttondown.email/jaffray/archive/why-are-query-plans...

[2] https://egraphs-good.github.io/

[3] https://www.scattered-thoughts.net/writing/materialize-decor...

(I'm the author of the original post [1]) And while I think the rules, in the end, make sense, I think it's not quite as clear cut as you describe, consider:

    SELECT (SELECT sum(1) FROM xx LIMIT 1) FROM aa;
which returns
    3
    3
    3
Personally, I think having the inner aggregation always attach to the nearest `SELECT` would have been an equally valid way of defining how this works, but it just so happens it is not defined that way.

[1] https://buttondown.email/jaffray/archive/sql-scoping-is-surp...

I agree, I think the original sin here is the fact that whether a `SELECT` is an aggregation is determined by the contents of the scalar expressions at all. I think most of this weirdness comes directly out of wanting to be able to write both `SELECT sum(x) FROM xx` and `SELECT x FROM xx` and have them work.

Not that I have a better solution offhand, in SQL grouping by a constant value is not actually the same as not writing `GROUP BY` at all since the behaviour on empty tables is different.

Joins 13 Ways 3 years ago

You are correct! I will fix it when I get home, thank you for the correction!

This implementation incidentally uses a hash table, but any set-like data structure would work. This is different from things like HyperLogLog that actually depend on the hash values themselves in order to work.

Thanks so much for the thoughtful response! TigerBeetle seems very cool, I hope to dig in and learn more about it at some point. As an aside, your Twitter thread on macOS fsync behaviour was very helpful for me!

Yes my intention was that it's more or less the reference version of that model, certainly databases like System R existed many years before Volcano :) I appreciate the correction.

Thank you for the nice comment, and for the lovely post on Prolog meta-interpreters that I linked here :) It seems I missed the part where you explicitly called out absorption and reification there! One of my reviewers actually suggested "elision" as well as reification after I had published the post, which seems quite similar.

And thanks for the info! I would love to learn more about compiler design and garbage collection in the future. Still working my way through some other reading materials but certainly something I would like to get to more!