Re: pg_trgm Memory Allocation logic

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
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 13:33:44
Message-ID: 1500.1425908024@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Beena Emerson <memissemerson(at)gmail(dot)com> writes:
> 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.

Consider input like 'X X X X X'. Each X produces 3 trigrams.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Meskes 2015-03-09 13:39:55 Re: Object files generated by ecpg test suite not ignored on Windows
Previous Message Heikki Linnakangas 2015-03-09 13:28:39 Re: pg_trgm Memory Allocation logic