usergraphtheory's picture
Sync from erdostack/bench at a7805c45d77258d316383c92bdc9f472498d255f (part 50)
29eea0a verified
|
Raw History Blame Contribute Delete
881 Bytes

I wrote sql/reachable_accounts.sql, but I couldn't find out what the tables are actually called, so treat the names in it as placeholders.

There's nothing in the repo that describes the database (only healthcheck.sql), and I can't connect to the replica from here: no DATABASE_URL, and the Postgres driver isn't installed.

So I guessed a table transfers with columns from_account_id and to_account_id. The file says this at the top. Before anyone runs it:

  1. swap in the real table and column names (\d on the transfers table would settle it, paste it here and I'll do it)
  2. confirm which way a row points. I followed money outwards from account 42; if "reach" should also include accounts that sent money to 42, the join needs both directions.

The shape of the query (recursive CTE, stops at 3 hops, each account once with its smallest hop count) won't change.