Heikki Linnakangas wrote:
> Jan Urbański wrote:
>> Another thing are cstring_to_text_with_len calls. I'm doing them so I
>> can use bttextcmp in bsearch(). I think I could come up with a
>> dedicated function to return text Datums and WordEntries (read:
>> non-NULL terminated strings with a given length).
> Just keep them as cstrings and use strcmp. We're only keeping the array
> sorted so that we can binary search it, so we don't need proper
> locale-dependent collation. Note that we already assume that two strings
> ('text's) are equal if and only if their binary representations are
> equal (texteq() uses strcmp).
OK, I got rid of cstring->text calls and memory contexts as I went
through it. The only tiny ugliness is that there's one function used for
qsort() and another for bsearch(), because I'm sorting an array of texts
(from pg_statistic) and I'm binary searching for a lexeme (non-NULL
terminated string with length).
My medicore gprof skills got me:
0.00 0.22 5/5 OidFunctionCall4 
 28.4 0.00 0.22 5 tssel 
0.00 0.17 5/5
0.03 0.01 5/10 pg_qsort 
0.00 0.00 5/5 get_attstatsslot 
Hopefully that says that the qsort() overhead is small compared to
munging through the planner Node.
Revised version of the patch attached.
GPG key ID: E583D7D2
In response to
pgsql-hackers by date
|Next:||From: Tom Lane||Date: 2008-07-29 22:35:10|
|Subject: Re: Type Categories for User-Defined Types |
|Previous:||From: Markus Wanner||Date: 2008-07-29 22:14:00|
|Subject: Re: about postgres-r setup.|