Sobes.tech
Senior

Postgres processed the information, understood that the data exists. What does it send back? Immediately the data as a row map or something else?

sobes.tech AI

Answer from AI

When Postgres processes a query and finds data, it does not immediately send it as a ready-made structure like a "row map" to the client. Instead, the server forms a set of result rows, which are transmitted to the client as streaming packets over the PostgreSQL protocol.

The process is roughly as follows:

  1. The server executes the query and forms the result — a set of rows.
  2. Each row is encoded in binary or text format, depending on the settings.
  3. These rows are sent to the client in a sequence of packets (DataRow).
  4. After all rows are transmitted, the server sends a CommandComplete packet, followed by ReadyForQuery.

Thus, the client receives data row by row, rather than all at once in a large structure. On the client side, the driver typically collects these rows into a convenient structure, such as a map or object.