Beena Emerson wrote:
> In the pg_trgm module, within function generate_trgm, the memory for trigrams
> is allocated as follows:
>
> trg = (TRGM *) palloc(TRGMHDRSIZE + sizeof(trgm) * (slen / 2 + 1) *3);
>
> I have been trying to understand why this is so because it seems to be
> allocating more space than that is required.
Maybe it's considering a worst-case for multibyte characteres? I don't
really know if trgm supports multibyte, but I assume it does. If it
does, then probably the trigrams consist of chars, not bytes.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services