Notes

# Zed screenshot

I’ve never been enthusiastic about the AI revolution.

However, this week, I started using Zed.dev together with their AI assistant integration. I’m surprised by the experience and efficiency gains. I still have reservations, but it can be valuable allies in tackling programming challenges and routine tasks.

For example, a few days ago, I was working on a tool that needed to parse ClickHouse explain output1, an easy task requiring recursively transverse all the properties looking for some specific properties.

With a simple prompt, the model wrote a working version.

Write code to extract all primary key granules from explain_result. An example of explain_result here:

{…}

def extract_primary_key_granules(explain_result):
    def traverse(node):
        granules = []
        if isinstance(node, dict):
            if 'Indexes' in node:
                for index in node['Indexes']:
                    if index.get('Type') == 'PrimaryKey':
                        granules.append({
                            'Keys': index.get('Keys', []),
                            'Initial Granules': index.get('Initial Granules', 0),
                            'Selected Granules': index.get('Selected Granules', 0)
                        })
            for value in node.values():
                granules.extend(traverse(value))
        elif isinstance(node, list):
            for item in node:
                granules.extend(traverse(item))
        return granules

    return traverse(explain_result)

# Example usage:
result = extract_primary_key_granules(explain_result)
for granule in result:
    print(f"Keys: {granule['Keys']}")
    print(f"Initial Granules: {granule['Initial Granules']}")
    print(f"Selected Granules: {granule['Selected Granules']}")
    print()

The task was relatively easy and I had to make changes and improve the initial code. Despite that, this saved me at least an hour of back-and-forth writing the function and running some tests to see if it worked as expected!

I started using Zed AI assistant with ChatGPT integration. A day after they released their own integration that I’m now testing together with Anthropic’s Claude model. I’m not even using Google for simple searches anymore.

Footnotes

  1. This is how a ClickHouse explain output looks like

#
#
  • Zed Decoded: Rope & SumTree — The Zed team explained how they use B+Tree (or SumTree) to deal with file content in their text editor. I have never considered how text editors use different structures to represent and manipulate huge strings while maintaining good performance. Interesting read.

  • Why does SQLite (in production) have such a bad rep? — A short post about the controversy around SQLite, a database often perceived as unsuitable for production. The most interesting thing is the discussions originated in lobste.rs and Reddit

  • In Codd we Trust (or not) — A brief reflection on Codd’s original idea, which separates logical and physical schema, and the significant role query planners and optimizers play in modern database performance. While I understand the point of letting experienced users write their queries and execute them as they are, I can’t fully agree.

  • Some opinionated thoughts on SQL databases — Another opinionated reflection on relational databases and SQL. I agree with some points. Still, SQL is here to stay. The point that resonated more is how inefficient it is to use SQL as an API in some workloads. I’ve seen query parsing take +50% of the processing time in low latency and high throughput environments. Of course, those numbers are for very specific use cases (e.g., point queries) where the data being read is small, taking just a few milliseconds. Still, the overhead is relevant, and there is little room for improvement when using plain SQL. On the other hand, it is good to use almost all relational databases using a single API language. If you are an experienced PostgreSQL user, you can query a MySQL database without investing hours learning how the new API works.

  • Senior Engineer Fatigue — An article to justify why older people get slower at their jobs. Jokes aside, it’s a good read about why sometimes you need to slow down to get faster. And it applies not only to senior engineers!

  • What Happens When You Put a Database in Your Browser? — The browser is the new OS. A DuckDB article about running their software in browsers using Wasm. The text provides a good example of pre-visualizing parquet file schema on the fly from the browser.