don't use 'NOT EXISTS', as this will be damn slow. Use LEFT JOIN.
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных