Thread: substring on bit(n) and bytea types is slow
On Feb 29, 2016 22:26, "Evgeny Morozov" <evgeny.morozov+list+pgsql@shift-technology.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.
On Feb 29, 2016 22:26, "Evgeny Morozov" <evgeny.morozov+list+pgsql@shift-technology.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.
On Feb 29, 2016 22:26, "Evgeny Morozov" <evgeny.morozov+list+pgsql@shift-technology.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.