> Attaching the first version patch which avoid CCI in RI trigger when insert > into > referencing table.
After some more on how to support parallel insert into fk relation. It seems we do not have a cheap way to implement this feature. Please see the explanation below: In RI_FKey_check, Currently, postgres execute "select xx for key share" to check that foreign key exists in PK table. However "select for update/share" is considered as parallel unsafe. It may be dangerous to do this in parallel mode, we may want to change this. And also, "select for update/share" is considered as "not read only" which will force readonly = false in _SPI_execute_plan. So, it seems we have to completely change the implementation of RI_FKey_check. At the same time, " simplifying foreign key/RI checks " thread is trying to replace "select xx for key share" with index_beginscan()+table_tuple_lock() (I think it’s parallel safe). May be we can try to support parallel insert fk relation after " simplifying foreign key/RI checks " patch applied ? Best regards, houzj