From: | Beena Emerson <memissemerson(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | pg_trgm Memory Allocation logic |
Date: | 2015-03-09 11:55:56 |
Message-ID: | 1425902156662-5841088.post@n5.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2015-03-09 12:08:49 | Re: [REVIEW] Re: Compression of full-page-writes |
Previous Message | Heikki Linnakangas | 2015-03-09 11:52:10 | Re: MD5 authentication needs help -SCRAM |