On Feb 29, 2016 22:26, "Evgeny Morozov" <
evgeny(dot)morozov+list+pgsql(at)shift-technology(dot)com> wrote
> SELECT substring(bitarray from (32 * (n - 1) + 1) for 32) -- bitarray is
a column of type bit(64000000)
> FROM array_test_bit
> JOIN generate_series(1, 10000) n ON true;
Substring on a bit string is not optimized for long TOASTed values.
Substring on text is optimized for that. The current code fetches the whole
8MB from the table every time.