On Thu, Dec 16, 2004 at 07:25:13PM -0500, Rudy Lippan wrote:
> On Tue, 14 Dec 2004, Tim Bunce wrote:
> 
> > On Tue, Dec 14, 2004 at 02:54:39PM +0900, [EMAIL PROTECTED] wrote:
> > > Hi.
> 
> >     if (PQgetisnull(imp_sth->result, imp_sth->cur_tuple, i)) {
> >             sv_setsv(sv, &sv_undef);
> > 
> > That would be significantly faster as:
> >             SvROK(sv) ? sv_unref(sv) : SvOK_off(sv);
> 
> Intersting. 1) How significant,

Significant is a wonderful word. It carries weight without much
absolute meaning :-)

In this case "significant" might mean 10 times as fast (guess),
but the effect on overall performance of DBD::Pg would be hard
to measure - even for result sets with many nulls.

Both SvROK and SvOK_off are simple macros expanding to very little code.
No function calls at all. sv_setsv, on the other hand, calls
sv_setsv_flags() which has a whole much of macros and tests before
it then short-circuits to doing SvOK_off.

> and 2) Do you think it would be worth the reduction in legability?

I don't see a reduction in legability :)

> >     } else {
> >             value = (char*)PQgetvalue(imp_sth->result, imp_sth->cur_tuple, 
> > i); 
> >             
> >             pg_type = PQftype(imp_sth->result, i);
> >             type_info = pg_type_data(pg_type);
> > 
> > Types don't vary between rows so the PQftype() and pg_type_data()
> > calls could be factored out of this inner-inner loop.
> 
> I see your point, but how much do you loose, 20 or so pushes and pops, a few 
> mvs
> per loop iteration, and how does that compare to pulling the data off the 
> wire?  

Doesn't pg fetch and cache all the rows off the wire in advance? 
So then the application fetching has a much shorter code path and
you stand a better chance of fitting more of it into the level2
data and instruction cache of the cpu. It all adds up either way.

> And then if you factor it out, you have to replace the above code with 
> something
> that indexes into array and that would probably make the code not quite as
> stright forward, but I am not totally against it; I just don't know if it 
> would 
> shave that much time off of the fetch?

You won't know unless you try :) I'm just pointing out that there's
possibly room for improvement. I've no idea how much - but you do have
the PG extension to "complete" with.

> imp_dbh->pg_enable_utf8 defaults to off.

Ah, good.

Tim.

Reply via email to