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.

columntypereferencesdescription
winfnoidregprocpg_proc.oidThe OID in pg_proc of the window function.
winrequireorderboolean The window function requires its window specification to have an ORDER BY clause.
winallowframeboolean The window function permits its window specification to have a ROWS or RANGE framing clause.
winpeercountboolean 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.
wincountboolean The partition row count is required to compute this window function.
winfuncregprocpg_proc.oidThe OID in pg_proc of a function to compute the value of an immediate-type window function.
winprefuncregprocpg_proc.oidThe OID in pg_proc of a preliminary window function to compute the partial value of a deferred-type window function.
winpretypeoidpg_type.oidThe OID in pg_type of the preliminary window function’s result type.
winfinfuncregprocpg_proc.oidThe 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.
winkindchar 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

Parent topic: System Catalogs Definitions