pg_window

The pg_window table stores information about window functions. Window functions are often used to compose complex OLAP (online analytical processing) queries. Window functions are applied to partitioned result sets within the scope of a single query expression. A window partition is a subset of rows returned by a query, as defined in a special OVER() clause. Typical window functions are rank, dense_rank, and row_number. Each entry in pg_window is an extension of an entry in pg_proc. The pg_proc entry carries the window function’s name, input and output data types, and other information that is similar to ordinary functions.

Table 1. pg_catalog.pg_window

column type references description
winfnoid regproc pg_proc.oid The OID in pg_proc of the window function.
winrequireorder boolean   The window function requires its window specification to have an ORDER BY clause.
winallowframe boolean   The window function permits its window specification to have a ROWS or RANGE framing clause.
winpeercount boolean   The peer group row count is required to compute this window function, so the Window node implementation must ‘look ahead’ as necessary to make this available in its internal state.
wincount boolean   The partition row count is required to compute this window function.
winfunc regproc pg_proc.oid The OID in pg_proc of a function to compute the value of an immediate-type window function.
winprefunc regproc pg_proc.oid The OID in pg_proc of a preliminary window function to compute the partial value of a deferred-type window function.
winpretype oid pg_type.oid The OID in pg_type of the preliminary window function’s result type.
winfinfunc regproc pg_proc.oid The OID in pg_proc of a function to compute the final value of a deferred-type window function from the partition row count and the result of winprefunc.
winkind char   A character indicating membership of the window function in a class of related functions:

w - ordinary window functions

n - NTILE functions

f - FIRST_VALUE functions

l - LAST_VALUE functions

g - LAG functions

d - LEAD functions