Re: pg_trgm Memory Allocation logic

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Beena Emerson <memissemerson(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_trgm Memory Allocation logic
Date: 2015-03-09 12:54:56
Message-ID: 20150309125456.GK3291@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2015-03-09 13:03:59 Re: Object files generated by ecpg test suite not ignored on Windows
Previous Message Andreas Karlsson 2015-03-09 12:39:04 Re: Using 128-bit integers for sum, avg and statistics aggregates