pg_trgm Memory Allocation logic

Поиск
Список
Период
Сортировка
От Beena Emerson
Тема pg_trgm Memory Allocation logic
Дата
Msg-id 1425902156662-5841088.post@n5.nabble.com
обсуждение исходный текст
Ответы Re: pg_trgm Memory Allocation logic  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Re: pg_trgm Memory Allocation logic  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
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 following table shows the palloced size [(slen / 2 + 1) *3] and the
actual trgm count for different string length.

slen    palloc size    actual trgm count
2    6        3
26    42        27
38    60        39

Can somebody please explain this to me.


I had tried changing the allocation to slen + 1 and it seemed to be working
without any problem.

trg = (TRGM *) palloc(TRGMHDRSIZE + sizeof(trgm) * (slen + 1)); 


Maybe I am missisng some scenarios. 

Any help would be appreciated.

Thank you,

Beena Emerson



-----

--

Beena Emerson

--
View this message in context: http://postgresql.nabble.com/pg-trgm-Memory-Allocation-logic-tp5841088.html
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: MD5 authentication needs help -SCRAM
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: [REVIEW] Re: Compression of full-page-writes