← All posts

Posts tagged #performance

Why Postgres ignores your trigram index: sargability, UPPER(), and an ORM that rewrites your query

10 min

You add a pg_trgm GIN index, the substring query gets no faster, and EXPLAIN shows a sequential scan. The operator is usually not the problem: pg_trgm serves ILIKE from the index perfectly well. What breaks it is a function wrapped around the column, and on Django that function is one your ORM adds for you. Measured at four table sizes, with the three fixes and what each costs.

A fast molecular-dynamics simulator in pure NumPy

11 min

A naive molecular-dynamics loop is O(N²) and dies past a few hundred particles. With cell lists, a cutoff Lennard-Jones potential, velocity-Verlet integration, and reduced units, you can simulate thousands of particles in pure NumPy and watch a gas equilibrate.