Skip to content

2.29.0.0-b50

@abhinab-yb abhinab-yb tagged this 14 Oct 03:42
Summary:
This diff adds support for `docdb_rows_returned` column in pg_stat_statements.

`docdb_rows_returned` is defined as the number of rows returned by storage layer
to query layer via RPCs for DMLs (SELECT / INSERT / UPDATE / DELETE) and
DDLs  (COPY / MATERIALIZED VIEW).

This does not include --
- rows returned by catalog requests (the metric is tracked and collected, but not exposed anywhere as of now)
- rows modified by DMLs (this can be found out from docdb_write_operations column)

With this, there will be 3 columns related to rows in pg_stat_statements --
- rows: Counts the number of rows returned by the query to the client.
- docdb_rows_scanned: Counts the number of rows scanned by the storage layer.
- docdb_rows_returned: Counts the number of rows returned by the storage layer to the query layer.

Use cases --
- docdb_rows_scanned >> docdb_rows_returned: indicates that an index is likely missing.
- docdb_rows_returned >> rows: indicates that the filter is too broad and needs to be narrowed down. In some cases, it can also point to inefficiencies in executing the query (such as not being able to pushdown a NOW() filter).

docdb_rows_returned is incremented for both read or a write ops because this
is like the output from docdb to the ysql layer.
Jira: DB-18191

Test Plan:
./yb_build.sh --java-test TestPgStatStatements#testDocdbRowsReturnedWithSelect
./yb_build.sh --java-test TestPgStatStatements#testDocdbRowsReturnedWithInsert
./yb_build.sh --java-test TestPgStatStatements#testDocdbRowsReturnedWithUpdate
./yb_build.sh --java-test TestPgStatStatements#testDocdbRowsReturnedWithDelete

Reviewers: kramanathan, ishan.chhangani

Reviewed By: kramanathan

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D46622
Assets 2
Loading