Re: pg_trgm Memory Allocation logic

Поиск
Список
Период
Сортировка
От Beena Emerson
Тема Re: pg_trgm Memory Allocation logic
Дата
Msg-id 1425970509753-5841238.post@n5.nabble.com
обсуждение исходный текст
Ответ на Re: pg_trgm Memory Allocation logic  (Heikki Linnakangas <hlinnaka@iki.fi>)
Список pgsql-hackers
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 allocated.

IIUC, for each word the total number of trigrams is: (word_length + LPADDING
+ RPADDING - 2).
Also the maximum number of words a string can have is: (slen +1)/2
(considering each word has length of 1)

I think (slen + (slen + 1)/2 * (LPADDING + RPADDING - 3) + 1) allocates only
the necessary memory for different values of RPADDING.

Regards,

Beena Emerson







-----

--

Beena Emerson

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



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

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: pg_rewind in contrib
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: Parallel Seq Scan