Relevant portions of my DDL:
CREATE TABLE report_entries (
report_entry_id SERIAL PRIMARY KEY,
...
);
CREATE TABLE bucket_joins (
deleted_id integer NOT NULL,
report_entry_id integer NOT NULL,
join_reason integer NOT NULL,
PRIMARY KEY(deleted_id, report_entry_id)
);
ALTER TABLE bucket_joins ADD CONSTRAINT fk_report_join
FOREIGN KEY (report_entry_id) REFERENCES report_entries (report_entry_id) ON DELETE CASCADE
;
ALTER TABLE bucket_joins ADD CONSTRAINT fk_deleted_join
FOREIGN KEY (deleted_id) REFERENCES report_entries (report_entry_id) ON DELETE CASCADE
;
I'm querying a group of rows from the report_entries table which includes the relevant soft-deleted rows, along with a prefetch to retrieve the collection of bucket_joins where report_entries.report_entry_id == bucket_join.report_entry_id.
I'm curious what the most efficient way to retrieve the ReportEntryEntity referenced by deleted_id because I know that I have already retrieved it in my initial query? I wasn't sure what mechanisms the runtime library use to avoid re-fetching an entity.
Thanks