\set ON_ERROR_STOP 1
\set ECHO queries

--vacuum analyze;

-- ---------------------------------
set enable_seqscan to on;
show enable_seqscan;

select pk_encounter
from clin.v_pat_items
where
	pk_episode = 58637 and
	pk_patient = 1687;

explain analyze select pk_encounter
from clin.v_pat_items
where
	pk_episode = 58637 and
	pk_patient = 1687;

-- ---------------------------------
set enable_seqscan to off;
show enable_seqscan;

select pk_encounter
from clin.v_pat_items
where
	pk_episode = 58637 and
	pk_patient = 1687;

explain analyze select pk_encounter
from clin.v_pat_items
where
	pk_episode = 58637 and
	pk_patient = 1687;

-- ---------------------------------
set enable_seqscan to on;
show enable_seqscan;

select pk_encounter
from clin.v_pat_items
where
	pk_health_issue = 3913 and
	pk_patient = 1687;

explain analyze select pk_encounter
from clin.v_pat_items
where
	pk_health_issue = 3913 and
	pk_patient = 1687;

-- ---------------------------------
set enable_seqscan to off;
show enable_seqscan;

select pk_encounter
from clin.v_pat_items
where
	pk_health_issue = 3913 and
	pk_patient = 1687;

explain analyze select pk_encounter
from clin.v_pat_items
where
	pk_health_issue = 3913 and
	pk_patient = 1687;
