Consider following before_update validation trigger on contracts table:
FOR i IN
SELECT uuid FROM tb_some_orders
WHERE is_deleted = 0 AND uuid_contract = NEW.uuid
LOOP
RAISE '#is_deleted#:deleting is prohibited due to dependent objects';
END LOOP;
tb_some_orders will contain about 1 mil of rows
What should happen, will db fetch all records or read each record or one by one?
Is there any need for LIMIT 1 as I do in app code?
existscondition will be way more efficient. In fact, a properly declared foreign key constraint would be a much better alternative to get rid of the trigger entirely.