Reposting, since it looks like the list changed from Yahoo to
Sourceforge. Sorry if everyone has read this already. I am still
looking things over to see what could be improved. DBI seems to already
be written in a clean, efficient way...
---
Today I had a tool I wrote using DBI and DBD_Pg running for about 8
hours before I gave up and killed it, then rewrote it using plain old
ruby-postgresql. The ruby-postgresql version ran in under 2 minutes.
It was line for line just about the same, except that the
ruby-postgresql ran queries over and over from the sql string where
the DBI did a prepare before entering the loop.
I am still trying to figure out what was going on. It's a really
basic loop. I select everyone from a table, and based on the value of
a certain field, I update a few values in the row from an array. So
it's an update wrapped in a select. Probably not especially
efficient, but it shouldn't have taken as long as it did.
Looking at sql.rb, there is some code that does a case to type bind
parameters. Numeric is the fall-through case, which seems odd since
numeric ids are so common. Perhaps moving it to the top could save a
few string comparisons?
I am willing to lose a little performance in exchange for all of the
cool things that DBI gives me, but I can't imagine the gulf should be
so wide. I am going to continue testing and make sure I didn't just
do something totally crazy and wrong, but in the mean time, I wonder
if any optimization fiends want to look at the DBD_Pg and DBI code?
Thanks,
Gabriel Emerson
|