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

From Tom Lane
Subject Re: pg_trgm Memory Allocation logic
Date
Msg-id 1500.1425908024@sss.pgh.pa.us
Whole thread Raw
In response to pg_trgm Memory Allocation logic  (Beena Emerson <memissemerson@gmail.com>)
Responses Re: pg_trgm Memory Allocation logic
List pgsql-hackers
Beena Emerson <memissemerson@gmail.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



pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: pg_trgm Memory Allocation logic
Next
From: Michael Meskes
Date:
Subject: Re: Object files generated by ecpg test suite not ignored on Windows