Re: [HACKERS] pg_trgm Memory Allocation logic

2015-03-09 Thread Beena Emerson
Hello, > If you manually set RPADDING 2 in trgm.h, then it will, but the > allocation probably should use LPADDING/RPADDING to get it right, rather > than assume the max values. Yes you are right. For RPADDING = 2, the current formula is suitable but for RPADDING =1, a lot of extra space is all

Re: [HACKERS] pg_trgm Memory Allocation logic

2015-03-09 Thread Heikki Linnakangas
On 03/09/2015 03:33 PM, Tom Lane wrote: Beena Emerson 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 becau

Re: [HACKERS] pg_trgm Memory Allocation logic

2015-03-09 Thread Tom Lane
Beena Emerson 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 spa

Re: [HACKERS] pg_trgm Memory Allocation logic

2015-03-09 Thread Heikki Linnakangas
On 03/09/2015 02:54 PM, Alvaro Herrera wrote: 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 becau

Re: [HACKERS] pg_trgm Memory Allocation logic

2015-03-09 Thread Alvaro Herrera
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 s

[HACKERS] pg_trgm Memory Allocation logic

2015-03-09 Thread Beena Emerson
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. The fo