CREATE INDEX IF NOT EXISTS bar_date_a_idx ON bar(date, a);

ALTER TABLE bar DROP CONSTRAINT IF EXISTS bar_date_a_fkey;

ALTER TABLE foo DROP CONSTRAINT IF EXISTS foo_pk;

LOAD 'auto_explain';
RESET ALL;
SET auto_explain.log_min_duration = 0;
SET auto_explain.log_analyze = on;
SET auto_explain.log_settings = on;
SET auto_explain.log_buffers = on;
SET track_io_timing = on;

ALTER TABLE foo ADD constraint foo_pk PRIMARY KEY(date, a);

ALTER TABLE bar ADD CONSTRAINT bar_date_a_fkey FOREIGN KEY(date, a) REFERENCES foo(date, a);

