News for hackers. Stuff that matters.

Tell HN: Citus is 100% open source now

https://github.com/citusdata/citus

I just realized this now, looks like Microsoft did it after they bought Citus? Good job!

Citus is a PostgreSQL extension that transforms Postgres into a distributed database.

    -- before adding the first worker node, tell future worker nodes how to reach the coordinator
    SELECT citus_set_coordinator_host('10.0.0.1', 5432);

    -- add worker nodes
    SELECT citus_add_node('10.0.0.2', 5432);
    SELECT citus_add_node('10.0.0.3', 5432);

    -- rebalance the shards over the new worker nodes
    SELECT rebalance_table_shards();
I am not affiliated with them, I just want to share this awesome OSS project.
( 9 comments | 31 points | on HN )
Re:Tell HN: Citus is 100% open source now by jlmorton on Friday September 02, 2022 @02:23PM (#32694123)
Re:Tell HN: Citus is 100% open source now by bombcar on Friday September 02, 2022 @02:22PM (#32694118)
SELECT causing changes to things makes me feel weird inside.
Re:Tell HN: Citus is 100% open source now by pcthrowaway on Friday September 02, 2022 @02:23PM (#32694131)
That's how every Postgres extension works (e.g. Timescale, PostGIS, etc.)
Re:Tell HN: Citus is 100% open source now by firloop on Friday September 02, 2022 @02:33PM (#32694254)
Not just Postgres extensions, most of Postgres’ own administrative functions can be triggered in SELECT statements. e.g. pg_terminate_backend()

https://www.postgresql.org/docs/current/functions-admin.html

Re:Tell HN: Citus is 100% open source now by yjftsjthsd-h on Saturday September 03, 2022 @12:28PM (#32703449)
To be quite clear, that always felt weird to me as well - something to the effect of "I thought SELECT was for reading data; why am I using it to create a replica?"
Re:Tell HN: Citus is 100% open source now by kaveet on Friday September 02, 2022 @02:28PM (#32694192)

  DO $$ BEGIN
      PERFORM rebalance_table_shards();
  END $$;
Re:Tell HN: Citus is 100% open source now by quickthrower2 on Friday September 02, 2022 @02:25PM (#32694157)
SELECT is a bit like return?

return 6;

or

return x++;

or even

return (exit(0));

Re:Tell HN: Citus is 100% open source now by colejohnson66 on Friday September 02, 2022 @02:28PM (#32694184)
I think GP is saying they view SELECT as a "pure" function. A pure function doesn't modify state, so neither should SELECT.
Re:Tell HN: Citus is 100% open source now by bombcar on Friday September 02, 2022 @02:33PM (#32694248)
Yeah, from limited experience with SQL "SELECT is safe" (assuming no weirdness in sub functions or commands) but that's clearly not always the case.