Faster perl / smaller PostgreSQL

jjore on 2007-10-07T03:53:18

I've two work-related thoughts I'd like to explore a little. The first is that I've noticed that the cost of invoking a very small XS accessor/mutator is about the same cost as doing a newSVsv(...) inside it. It occurs to me that I could avoid some copies if lexicals being passed into my accessor were marked as SvTMP if their use was the last mention in the calling code.

Consider:

{
    my $foo = 1;
    bar( $foo ); # $foo is now stealable
}


I imagine I'd go through the compiled code, find the points where lexicals are last used and insert an operation just prior which would turn the TMP flag on. This is trading a bit of additional space and runtime length for avoiding copies of data. Maybe it helps. Dunno.

Here's the other thought. At work I have lots of records for households of people. To efficiently search for a person and their household, a single household record is exploded out to one for all the people in the dwelling. PostgreSQL has usertypes. I've thought it would be nice to store a set of last names (among other fields) in an array.

Initially looking, the PostgreSQL GIN index type appears to do most of this natively already. I've a drawback in that I can't use multicolumn GIN indexes. :-(