in reply to Inheritance in XS modules?

I suspect that you are trying to optimize the wrong end of the problem. My experience in writing database apps in perl has been that the time spent in the database executing the queries, and fetching the data far outweigh the CPU time of the perl subroutines.

Michael

Replies are listed 'Best First'.
MySQL C API vs. DBI for performance (was Re: Re: Inheritance in XS modules?)
by blue_cowdawg (Monsignor) on Sep 09, 2003 at 21:07 UTC

    Actually, I have two sets of thoughts on that matter. One is the fact that the DBI doco itself IIRC says right in it that the DBI interface is not horribly efficient.

    Second is one of the major reasons I went with an inheritance structure in the pure Perl version was so connections are made ONCE and not for every object that needs to get data from the database.

    As far as if a C API interface is going to buy me anything... the jury is still out. I have to get the C API code to work before I can benchmark it.


    Peter L. Berghold -- Unix Professional
    Peter at Berghold dot Net
       Dog trainer, dog agility exhibitor, brewer of fine Belgian style ales. Happiness is a warm, tired, contented dog curled up at your side and a good Belgian ale in your chalice.
      One is the fact that the DBI doco itself IIRC says right in it that the DBI interface is not horribly efficient.

      Actually the DBI documentation says the complete opposite. From the FAQ "How fast is the DBI?":

      ... DBI and DBD::Oracle overheads are small compared with Perl language overheads (and probably database overheads).

      This matches my experience. If DBI isn't fast enough your problem is almost certainly IO, hardware or the choice of Perl as the implementation language. DBI was designed for speed - I doubt you'll see much improvement without moving most of your application onto the XS side.

      If you've not read it already I'd give Tim's DBI Advanced Talk a look over. It has lots of relevant tips on getting the most from DBI.

            If DBI isn't fast enough your problem is almost certainly IO, hardware or the choice of Perl as the implementation language.
        I/O and hardware, unfortunately in this case, is out of my control. Hosted ISP site. Even the version of Perl is something I'm locked into. Version 5.005_03 and I'm sure not the latest and greatest DBI.

        Maybe I should just leave this project as an intellectual excersize. Still it might make a great PM Mediation when I do the benchmarks... :-)


        Peter L. Berghold -- Unix Professional
        Peter at Berghold dot Net
           Dog trainer, dog agility exhibitor, brewer of fine Belgian style ales. Happiness is a warm, tired, contented dog curled up at your side and a good Belgian ale in your chalice.
      My tests with DBD::Sybase vs. Sybase::CTlib actually show that DBI is pretty efficient - there isn't really any difference between the two in terms of speed. You might argue that this is because Sybase::CTlib is badly written, of course... :-)

      Michael