frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Pgtestdb's template cloning approach to testing is fast

https://brandur.org/fragments/pgtestdb
11•brandur•58m ago

Comments

hugodutka•28m ago
Cloning a template is IO-heavy. You can speed it up further by putting postgres on a ramdisk.
ltbarcly3•18m ago
Just turning off fsync is basically just as fast as a ramdisk and you can't use up all your memory with one big test.
ltbarcly3•19m ago
Our db clearing takes like 5ms (large schema from mature company, not a toy). We start by restoring a production schema dump which ensures our test db / devdb schema is basically identical to what we run in production. Any migrations you are working on in your branch get added to the restore of the prod schema after it runs. Building a schema from ORM definitions is what you do if you don't care about your life or time. Clearing the test db takes something similar. This is fine, using template db's is a good way to make a scratch copy of a local database to test migrations (rsync is better if you are technical enough to use it to restore after destructive changes).

Timings:

  - create testdb: 9ms
  - restore prod schema: 500ms (done once per test process)
  - clear test data in 96 tables between tests that write to db (5ms)
The fastest way to clear a test db is to run a query to get every schema/table name, then run ";".join("`DELETE FROM {schema}.{tablename};" for schema, table in my_tables) after putting the db in replica mode. This takes single digit ms a lot of the time even with a decent amount of test data. I've done it every which way and this is by far the fastest way to clear data between tests.

    test_db_2235191=# CREATE OR REPLACE PROCEDURE public.delete_all_table_data()
        LANGUAGE plpgsql
        AS $procedure$
        DECLARE
            target record;
            previous_replication_role text;
        BEGIN
            previous_replication_role :=
                current_setting('session_replication_role');
        PERFORM set_config('session_replication_role', 'replica', true);

        BEGIN
            FOR target IN
                SELECT namespace.nspname AS schema_name,
                       relation.relname AS table_name
                FROM pg_catalog.pg_class AS relation
                JOIN pg_catalog.pg_namespace AS namespace
                  ON namespace.oid = relation.relnamespace
                WHERE relation.relkind = 'r'
                  AND namespace.nspname NOT LIKE 'pg\_%' ESCAPE '\'
                  AND namespace.nspname <> 'information_schema'
                ORDER BY namespace.nspname, relation.relname
            LOOP
                RAISE NOTICE 'Deleting %.%',
                    target.schema_name,
                    target.table_name;

                EXECUTE format(
                    'DELETE FROM %I.%I',
                    target.schema_name,
                    target.table_name
                );
            END LOOP;
        EXCEPTION
            WHEN OTHERS THEN
                PERFORM set_config(
                    'session_replication_role',
                    previous_replication_role,
                    true
                );
                RAISE;
        END;

        PERFORM set_config(
            'session_replication_role',
            previous_replication_role,
            true
        );
    END;
    $procedure$;
    CREATE PROCEDURE
    Time: 0.840 ms


    test_db_2235191=# CALL public.delete_all_table_data();
    NOTICE:  ... (notices removed for 96 tables)
    CALL
    Time: 5.855 ms

The Kotlin Benchmark for AI Coding Agents

https://blog.jetbrains.com/kotlin/2026/07/introducing-the-kotlin-benchmark-evaluate-ai-coding-age...
1•yruzin•41s ago•0 comments

Tesla Spyware

https://ma.tt/2026/07/tesla-spyware/
1•speckx•50s ago•0 comments

Floundering A.I. 'Nostradamus' Hedge Fund Is Rescued by Rival

https://www.nytimes.com/2026/07/30/business/artificial-intelligence-situational-awareness-citadel...
1•thm•2m ago•0 comments

The Process Is the Point

https://seekingtrust.substack.com/p/the-process-is-the-point-on-asymmetric
2•FinnLobsien•3m ago•0 comments

LLMs Can't Jump [pdf]

https://www.tomzahavy.com/files/llms-cant-jump.pdf
2•root-parent•6m ago•0 comments

DNS propagation checker that shows the results as a box of 24 donuts

https://donutdns.com
2•axeldelat•6m ago•0 comments

I ♥ RSS – A directory of people who love RSS

https://andrewshell.org/2026/07/i-%e2%99%a5-rss/
3•speckx•6m ago•0 comments

Twelve Years Without a VPN

https://khessin.de/twelve-years-without-a-vpn/
1•taubek•6m ago•0 comments

The Dartmouth Workshop: The $7,500 investment that gave birth to AI

https://www.france24.com/en/technology/20260801-the-dartmouth-workshop-the-7-500-investment-that-...
1•hackthemack•7m ago•0 comments

Ranked: Where the iPhone Costs the Most in 2026

https://www.visualcapitalist.com/ranked-where-iphones-cost-the-most-in-2026/
1•cyberlurker•8m ago•0 comments

World Radio History

https://www.worldradiohistory.com/index.htm
1•gregsadetsky•13m ago•0 comments

Kaisel – Routes as Values. Dart 3 Native Router for Flutter

https://kaisel.dev/
3•TheWiggles•13m ago•0 comments

Franken.domains: Stitched-Together Domains, Because Every .com Is Taken

https://franken.domains/
2•klausbreyer•14m ago•0 comments

Amazon spent $1.8M using Claude for menial coding task, went 860% over budget

https://www.tomshardware.com/tech-industry/artificial-intelligence/amazon-accidentally-spent-usd1...
1•PLenz•14m ago•0 comments

US authorities see 'significant escalation' in attacks on water system devices

https://www.cybersecuritydive.com/news/us-authorities-escalation-attacks-water-system-devices/826...
2•ripe•16m ago•0 comments

Simplicity

https://commandcenter.blogspot.com/2023/12/simplicity.html
2•pbohun•18m ago•0 comments

I Fired My AI Assitant

https://chreke.com/posts/i-fired-my-ai-assistant
1•speckx•20m ago•0 comments

When AI Starts Writing Systems Code

https://www.coreauto.com/blog/when-ai-starts-writing-systems-code
1•skidrow•21m ago•0 comments

We stopped using RSC on Tanstack.com

https://tanstack.com/blog/we-stopped-using-rsc-on-tanstack-com
1•agos•22m ago•0 comments

An AI radio station that draws a live comic of its hosts' thoughts

https://hiveweaver.fm/en/
1•Yesbert•22m ago•0 comments

An Open Letter to AI for Generating Gnome Shell Extensions

https://blogs.gnome.org/jrahmatzadeh/2026/07/27/ego-ai-reference/
1•Shock9889•22m ago•0 comments

Arch Linux disables AUR package adoption to stop malware flood

https://www.bleepingcomputer.com/news/security/arch-linux-disables-aur-package-adoption-to-stop-m...
1•Brajeshwar•22m ago•0 comments

Better tools made Copilot code review worse. Here's how we actually improved it

https://github.blog/ai-and-ml/github-copilot/better-tools-made-copilot-code-review-worse-heres-ho...
1•opwizardx•23m ago•0 comments

Go 1.27 Interactive Tour

https://victoriametrics.com/blog/go-1-27/index.html
1•birdculture•23m ago•0 comments

Show HN: Goulash – heckler/helper to local-LLM your shell as little as possible

https://github.com/chaboud/goulash
1•chaboud•25m ago•0 comments

Show HN: An MCP server that knows what that error message means

https://errors.standardbeagle.com/
1•andybrummer•25m ago•0 comments

Scientists using LLMs will 'do more, less well', modelling study predicts

https://www.nature.com/articles/d41586-026-02397-5
2•bookofjoe•28m ago•1 comments

Show HN: BillDesk – Offline invoicing for freelancers (Windows and Mac)

https://getbilldesk.vercel.app
1•afif1710•37m ago•0 comments

How to Read Mathematics? A Study Guide

https://arxiv.org/abs/2607.24136
2•tcp_handshaker•37m ago•0 comments

Aispa: User-Centric System Prompt Auditing for Large Language Model Applications

https://arxiv.org/abs/2607.28617
1•tcp_handshaker•39m ago•0 comments