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.


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to