Jeff Frost <jeff(at)frostconsultingllc(dot)com> writes:
> delete from visit where id not in (select distinct visit_id from page_view);
> This yields the following error:
> ERROR: update or delete on "visit" violates foreign key constraint
> "fk34afd255fbacabec" on "page_view"
> DETAIL: Key (id)=(38635629) is still referenced from table "page_view".
This seems pretty darn weird. I am wondering about corrupt indexes ---
can you find the indicated key in either table if you set
enable_indexscan and enable_bitmapscan to 0?
Also, this is a long shot, but does visit by any chance have a cascading
deletion self-reference?
regards, tom lane