Archive for April, 2024

Drawing Rounded Rectangles

Monday, April 29th, 2024

While working on my little game, I’ve iterated through different ways of displaying game state:

  1. Command line
  2. Web page
  3. 2D canvas
  4. 3D canvas

In each port, I preserve some elements and change others out. One of the elements I want to keep from the 2D version in the 3D version is rounded rectangles.

Initially, I used NanoVG to render the 2D elements into 3D. This works, but NanoVG is a lot of code. It’s very general. I don’t need that level of generality. I just want rounded rectangles. So how do we do that?

(more…)

What is Plausible Doing For You?

Monday, April 22nd, 2024

Plausible is a privacy-focused analytics service. It is available hosted by them, or can be run on your own. What does it do for you? We’ll explore a bit of the journey from a user visiting a web page, to that page view appearing in the analytics dashboard. (more…)

SQL INSERT to COPY FROM Conversion

Monday, April 15th, 2024

While reproducing an example from ClickHouse’s blog, I needed to insert some data provided as SQL with INSERT statements.

INSERT is the standard transactional way to insert data into a database. There’s nothing wrong with it. But when you’re trying to insert data into a PostgreSQL database in bulk, there’s a better way: COPY FROM.

When using COPY, PostgreSQL itself will read and parse a file full of row data and insert it into a table. There is very little overhead of parsing SQL, etc. This is the format used by pg_dump by default when producing an SQL dump output. But, to use it, the input data must be in the right format. PostgreSQL explains the format it expects in its documentation. It’s basically TSV with a couple of provisions for escaping values.

On the other hand, the input we’ve got is an SQL file looking like this: (more…)

Reproducing ClickHouse Postgres Integration Example

Monday, April 8th, 2024

I was recently reading this article from ClickHouse demonstrating ClickHouse’s integration with Postgres and performance characteristics. I followed along. Here are my notes.

My experimental setup was slightly different. Rather than using hosted services (Supabase and ClickHouse Cloud), I ran everything locally on my M2 MacBook Air. Versions in question:

  • PostgreSQL 15.6 (Postgres.app) on aarch64-apple-darwin21.6.0, compiled by Apple clang version 14.0.0 (clang-1400.0.29.102), 64-bit
  • ClickHouse server version 23.12.4.15 (official build).

(more…)