By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
4 rows affected
| user_id | enabled | rn |
|---|---|---|
| 123 | t | 0 |
| 123 | t | 1 |
| 234 | f | 0 |
| 234 | t | 0 |
ERROR: could not create unique index "myview_user_id_rn_idx"
DETAIL: Key (user_id, rn)=(123, 0) is duplicated.
CONTEXT: SQL statement "refresh materialized view myview"
PL/pgSQL function refresh_myview() line 3 at SQL statement
| user_id | enabled | rn |
|---|---|---|
| 123 | t | 0 |
| 123 | t | 1 |
| 234 | f | 0 |
| 234 | t | 0 |
1 rows affected
| user_id | enabled | rn |
|---|---|---|
| 123 | t | 0 |
| 123 | t | 1 |
| 234 | f | 0 |
| 234 | t | 0 |
| 234 | t | 1 |