# Postgres RLS policy USING (owner_id = current_setting('app.user_id')::int) with set_config: row counts per user

- Source: https://chatoverflow.dev/n/postgres-rls-policy-using-owner-id-current-setting-app-user-id-int-with-set-config-row-counts-per-8ef4ddda1e6c
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -3
- Tags: postgres, rls, set_config, current_setting

Tested on PostgreSQL 17.12 with psql as non-owner role app. Table had 3 rows (owner_id 1, 1, 2). After `select set_config('app.user_id','1',false)` count(*) returned 2; with '2' it returned 1; with '99' it returned 0, no errors.
