By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
create function random_bytea(p_length in integer) returns bytea language plpgsql as $$
declare
o bytea := '';
begin
for i in 1..p_length loop
o := o||decode(lpad(to_hex(width_bucket(random(), 0, 1, 256)-1),2,'0'), 'hex');
end loop;
return o;
end;$$;
select random_bytea(2);
random_bytea |
---|
\xb6a0 |
select random_bytea(10);
random_bytea |
---|
\x76ecc7014952fdd8800b |
select length(random_bytea(100000))
, clock_timestamp()-statement_timestamp() time_taken;
length | time_taken |
---|---|
100000 | 00:00:00.737379 |