Skip to content

sys.const

This persistent table stores one row with one column and a constant integer value of 1. Because this table has only one row, you can use it to return exactly one row for the result of a function or constant expression. You can use any other table in your database to compute the same result, but the result will be returned once for every row in that table. By using the sys.const table, you guarantee that only one row will be returned.

The Yellowbrick planner is aware of the sys.const table so queries may gain a performance benefit from using sys.const rather than some other table.

premdb=# \d sys.const
     Table "sys.const"
 Column |  Type   | Modifiers 
--------+---------+-----------
 one    | integer | not null
premdb=# select * from sys.const;
 one 
-----
   1
(1 row)
premdb=# select current_date from sys.const;
   date    
------------
 2016-07-13
(1 row)

Tip: This table is similar in functionality to the dual table in Oracle databases.

Parent topic:System Views