Re: gsoc, oprrest function for text search take 2

From: Jan Urbański <j(dot)urbanski(at)students(dot)mimuw(dot)edu(dot)pl>
To: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
Cc: Postgres - Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: gsoc, oprrest function for text search take 2
Date: 2008-07-29 22:17:09
Message-ID: 488F96E5.4020308@students.mimuw.edu.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 [37]
[38] 28.4 0.00 0.22 5 tssel [38]
0.00 0.17 5/5
get_restriction_variable [40]
0.03 0.01 5/10 pg_qsort [60]
0.00 0.00 5/5 get_attstatsslot [139]

Hopefully that says that the qsort() overhead is small compared to
munging through the planner Node.
Revised version of the patch attached.

Cheers,
Jan

--
Jan Urbanski
GPG key ID: E583D7D2

ouden estin

Attachment Content-Type Size
tssel-gsoc08-tss-v2.patch text/plain 13.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-07-29 22:35:10 Re: Type Categories for User-Defined Types
Previous Message Markus Wanner 2008-07-29 22:14:00 Re: about postgres-r setup.