Database view listing distinct days
create materialized view foo as 
  select distinct machine_code, date(datetime) from thing;

create unique index on foo(machine_code,date);


Beware that the conversion of datetime to date will occur in the timezone of whoever last created or refreshed the MV.  You might want to use this instead:

create materialized view foo as 
  select distinct machine_code, date(datetime at time zone 'GMT+1') from thing;


But that might not do what you want with daylight savings time.