Re: pg_trgm Memory Allocation logic - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: pg_trgm Memory Allocation logic
Date
Msg-id 20150309125456.GK3291@alvh.no-ip.org
Whole thread Raw
In response to pg_trgm Memory Allocation logic  (Beena Emerson <memissemerson@gmail.com>)
Responses Re: pg_trgm Memory Allocation logic  (Heikki Linnakangas <hlinnaka@iki.fi>)
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Andreas Karlsson
Date:
Subject: Re: Using 128-bit integers for sum, avg and statistics aggregates
Next
From: Alvaro Herrera
Date:
Subject: Re: Object files generated by ecpg test suite not ignored on Windows