Appearance
sys.worker_id()
Return the logical ID of the worker node that runs this function.
sys.worker_id()
To return a meaningful result, always use this function in a query with a table reference, such as a reference to sys.const.
The following repeated queries return a different worker ID, depending on which worker runs the query in each case.
premdb=# select sys.worker_id() from sys.const;
worker_id
-----------
9
(1 row)
premdb=# select sys.worker_id() from sys.const;
worker_id
-----------
3
(1 row)
premdb=# select sys.worker_id() from sys.const;
worker_id
-----------
8
(1 row)
The query counts the number of rows by the worker that processed the row (not the worker where the rows are stored).
premdb=# select sys.worker_id(), count(*) from newmatchstats group by 1 order by 1;
worker_id | count
-----------+--------
0 | 68400
1 | 34200
4 | 41580
5 | 75780
6 | 34200
7 | 34200
8 | 102600
9 | 102600
10 | 144180
12 | 68400
13 | 68400
(11 rows)
Parent topic:System Functions