Re: pg_trgm Memory Allocation logic
От | Heikki Linnakangas |
---|---|
Тема | Re: pg_trgm Memory Allocation logic |
Дата | |
Msg-id | 54FDA97C.8020205@iki.fi обсуждение исходный текст |
Ответ на | Re: pg_trgm Memory Allocation logic (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: pg_trgm Memory Allocation logic
|
Список | pgsql-hackers |
On 03/09/2015 03:33 PM, Tom Lane wrote: > 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. No it won't. Only two: postgres=# select show_trgm('a b c'); show_trgm --------------------------------------- {" a"," b"," c"," a "," b "," c "} (1 row) 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. - Heikki
В списке pgsql-hackers по дате отправления: