Re: substring on bit(n) and bytea types is slow - Mailing list pgsql-general

From Arjen Nienhuis
Subject Re: substring on bit(n) and bytea types is slow
Date
Msg-id CAG6W84K_WeGeXc0KY7csygh+3XftRaz4J40x3Wc-QC-r+y6=xg@mail.gmail.com
Whole thread Raw
In response to substring on bit(n) and bytea types is slow  (Evgeny Morozov <evgeny.morozov+list+pgsql@shift-technology.com>)
Responses Re: substring on bit(n) and bytea types is slow  (Evgeny Morozov <evgeny.morozov@shift-technology.com>)
List pgsql-general


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.

pgsql-general by date:

Previous
From: Scott Mead
Date:
Subject: Re: Schema Size
Next
From: "drum.lucas@gmail.com"
Date:
Subject: Re: Function fixing - PostgreSQL 9.2