

 Amazon Redshift will no longer support the creation of new Python UDFs starting Patch 198. Existing Python UDFs will continue to function until June 30, 2026. For more information, see the [ blog post ](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/). 

# PG\$1BACKEND\$1PID
<a name="PG_BACKEND_PID"></a>

Returns the process ID (PID) of the server process handling the current session.

**Note**  
The PID is not globally unique. It can be reused over time.

## Syntax
<a name="PG_BACKEND_PID-synopsis"></a>

```
pg_backend_pid()
```

## Return type
<a name="PG_BACKEND_PID-return-type"></a>

Returns an integer.

## Example
<a name="PG_BACKEND_PID-example"></a>

You can correlate PG\$1BACKEND\$1PID with log tables to retrieve information for the current session. For example, the following query returns the query ID and a portion of the query text for queries completed in the current session.

```
select query, substring(text,1,40)
from stl_querytext
where pid =  PG_BACKEND_PID()
order by query desc;

 query |                substring
-------+------------------------------------------
 14831 | select query, substring(text,1,40) from
 14827 | select query, substring(path,0,80) as pa
 14826 | copy category from 's3://dw-tickit/manif
 14825 | Count rows in target table
 14824 | unload ('select * from category') to 's3
(5 rows)
```

You can correlate PG\$1BACKEND\$1PID with the pid column in the following log tables (exceptions are noted in parentheses):
+ [STL\$1CONNECTION\$1LOG](r_STL_CONNECTION_LOG.md)
+ [STL\$1DDLTEXT](r_STL_DDLTEXT.md)
+ [STL\$1ERROR](r_STL_ERROR.md)
+ [STL\$1QUERY](r_STL_QUERY.md)
+ [STL\$1QUERYTEXT](r_STL_QUERYTEXT.md)
+ [STL\$1SESSIONS](r_STL_SESSIONS.md) (process)
+ [STL\$1TR\$1CONFLICT](r_STL_TR_CONFLICT.md)
+ [STL\$1UTILITYTEXT](r_STL_UTILITYTEXT.md)
+ [STV\$1ACTIVE\$1CURSORS](r_STV_ACTIVE_CURSORS.md)
+ [STV\$1INFLIGHT](r_STV_INFLIGHT.md)
+ [STV\$1LOCKS](r_STV_LOCKS.md) (lock\$1owner\$1pid)
+ [STV\$1RECENTS](r_STV_RECENTS.md) (process\$1id)