This function will dynamically query one week at a time up to the limit hopefully taking advantage of the partitioning. SQL Fiddle
create or replace function unit_position_limited_by(l integer)
returns setof unit_position
language plpgsql as $function$
declare
week timestamp := date_trunc('week', transaction_timestamp());
total integer := 0;
inserted integer;
not_exists boolean;
begin
loop
return query execute $$
select *
from unit_position
where
unit_id = 1
and obs_time >= $1 and obs_time < $2
order by obs_time desc
limit $3
$$ using week, week + interval '1 week', l - total;
get diagnostics inserted := row_count;
total := total + inserted;
exit when total = l;
if inserted = 0 then
execute $$
select not exists (
select 1
from unit_position
where obs_time < $1
)
$$ into not_exists using week;
exit when not_exists;
end if;
week := week - interval '1 week';
end loop;
end; $function$;
To select from it:
select *
from unit_position_limited_by(1000);