Re: [cx-oracle-users] Help with fetchraw
Brought to you by:
atuining
From: Anthony T. <ant...@gm...> - 2005-05-17 13:27:07
|
On 5/17/05, Chris Dunscombe <cdu...@ya...> wrote: >=20 > --- Anthony Tuininga <ant...@gm...> wrote: > > 2) I'm not sure exactly what you are intending with this so I can't > > see why the simple > > > > for row in cursor: > > process_the_row() > > > > isn't going to work or isn't desirable. Perhaps you could give more > > detail? Thanks. >=20 > The "problem" with: >=20 > for row in cursor: > process_the_row() >=20 > is that process_the_row() is essentially: >=20 > for col in row: > rowOut =3D rowOut.append(format_col(col)) > rowOutString =3D "".join(rowOut) >=20 > which creates quite an overhead when the tables have lots of columns (>40= ). You should be able to rewrite "process_the_row()" as the following if all you are intending to do is replace None with "" for row in cursor: rowOutString =3D "".join([v or "" for v in row]) if all you are fetching is strings. There is a flag for turning numbers into strings in all cases as well. If you need something more complicated than the above (multiple data types) then I'll need more information. :-) > So I'm looking at anything that could help speed things up (it's quite po= ssible that in this case > fetchraw() won't make much of an impact compared to the process_the_row()= code) This is why I'm > looking the None as Null returning "" stuff so as to reduce the complexit= y of "format_col()" and > hence CPU cost. >=20 > BTW I've actually put the process_the_row and format_col() code in-line a= s per > http://www.python.org/doc/faq/programming.html and associated performance= guidelines to avoid the > function call overhead and this reduced the Python CPU usage by almost 20= % on my standard perf > test. >=20 > Thanks again for your much appreciated help, You're welcome. I hope to get the example of fetchraw() to you later today but I expect to be interrupted shortly with a task that might take all day so don't be alarmed if you don't hear from me right away. I haven't forgotten about it. :-) > Chris > > On 5/12/05, Chris Dunscombe <cdu...@ya...> wrote: > > > I'm looking to use cursor.fetchraw to help improve performance in an = app I'm writing. I've > > looked > > > at CopyData from cx_OracleTools but I'm afraid I couldn't work it out= . > > > If possible I'd like a simple full example to show me the way. The co= ntext is: > > > > > > 1) Retrieve rows from source table and insert into a target table whi= ch has exactly the same > > > structure. > > > > > > 2) Retrieve rows from source table, add some column formatting and wr= ite out to a file. > > > > > > Thanks very much, > > > > > > Chris Dunscombe > > > > > > PS Thanks for all the input re my previous posting on Nulls and None.= I've still got some > > thinking > > > and work to do on which is best for performance and how best to cope = with different datatypes, > > > particularly Longs (what a pain they are!!) > > > > > > __________________________________ > > > Yahoo! Mail Mobile > > > Take Yahoo! Mail with you! Check email on your mobile phone. > > > http://mobile.yahoo.com/learn/mail > > > > > > ------------------------------------------------------- > > > This SF.Net email is sponsored by Oracle Space Sweepstakes > > > Want to be the first software developer in space? > > > Enter now for the Oracle Space Sweepstakes! > > > http://ads.osdn.com/?ad_id=3D7393&alloc_id=3D16281&op=3Dclick > > > _______________________________________________ > > > cx-oracle-users mailing list > > > cx-...@li... > > > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by Oracle Space Sweepstakes > > Want to be the first software developer in space? > > Enter now for the Oracle Space Sweepstakes! > > http://ads.osdn.com/?ad_idt12&alloc_id=16344&op=3Dclick > > _______________________________________________ > > cx-oracle-users mailing list > > cx-...@li... > > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > >=20 > __________________________________ > Yahoo! Mail Mobile > Take Yahoo! Mail with you! Check email on your mobile phone. > http://mobile.yahoo.com/learn/mail >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by Oracle Space Sweepstakes > Want to be the first software developer in space? > Enter now for the Oracle Space Sweepstakes! > http://ads.osdn.com/?ad_id=3D7412&alloc_id=3D16344&op=3Dclick > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |