Search code examples
postgresqlherokurowtuples

What's the difference between a tuple and a row in Postgres?


My general understanding is that a tuple is a row. However, I'm using the Postgres dev plan in Heroku. It has a limit of 10,000 rows. I have over 100,000 entries for n_live_tup. How can this be?


Solution

  • "Tuple" is the abstract term, "row" is for the concrete implementation.
    Just like "relation" versus "table".

    In Postgres' MVCC implementation, multiple instances of the same table row can exist concurrently - for different snapshots of the same table or as obsolete "dead tuples". In Postgres parlance "row" is the umbrella term in this case and "tuple" is used for one instance. But that's more what you call guidelines than actual rules.

    Otherwise the terms are often used meaning the same. You can find more for each of them in Wikipedia.

    No idea what's behind the Heroku policies. But the numbers for n_live_tup in pg_stat_user_tables or pgstattuple represents "the number of live rows" in the table. See: