I have a multi-column unique index in postgresql. Sometimes one of these column values will be NULL, and I'd like the unique index to treat NULL as just another value. So that these two rows are NOT allowed:
1,2,NULL
1,2,NULL
Doing simple experiments at psql, this is exactly the behavior I see.
But I have a stress test where I do 20 concurrent inserts using 20 threads. Here, Postgres allows the identical rows to be inserted.
Is there any reason for this to happen? Maybe there's another difference between my psql experiment and my test experiment.