Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 584
Bailey Smith Avatar asked Nov 05 '13 21:11

Bailey Smith


People also ask

What is the difference between tuple and row?

A table has rows and columns, where rows represents records and columns represent the attributes. Tuple − A single row of a table, which contains a single record for that relation is called a tuple. Relation instance − A finite set of tuples in the relational database system represents relation instance.

What is a tuple in PostgreSQL?

A tuple is PostgreSQL's internal representation of a row in a table. A single row may have many tuples representing it, but only one of these tuples will be applicable at any single point in time.

What is a row in PostgreSQL?

Introduction to the PostgreSQL ROW_NUMBER() function The ROW_NUMBER() function is a window function that assigns a sequential integer to each row in a result set. The following illustrates the syntax of the ROW_NUMBER() function: ROW_NUMBER() OVER( [PARTITION BY column_1, column_2,…] [ORDER BY column_3,column_4,…] )

What is a tuple a row or record?

In the context of a relational database, a row—also called a tuple—represents a single, implicitly structured data item in a table. In simple terms, a database table can be thought of as consisting of rows and columns. A tuple is a finite sequence of attributes, which are ordered pairs of domains and values.


1 Answers

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

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 your table.
See:

  • What is the meaning of n_live_tup and n_dead_tup in pg_stat_user_tables
like image 75
Erwin Brandstetter Avatar answered Sep 28 '22 10:09

Erwin Brandstetter