Re: [cx-oracle-users] Help with fetchraw
Brought to you by:
atuining
From: Chris D. <cdu...@ya...> - 2005-05-17 15:28:01
|
--- Anthony Tuininga <ant...@gm...> wrote: > On 5/17/05, Chris Dunscombe <cdu...@ya...> wrote: > > > > --- 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. > > > > The "problem" with: > > > > for row in cursor: > > process_the_row() > > > > is that process_the_row() is essentially: > > > > for col in row: > > rowOut = rowOut.append(format_col(col)) > > rowOutString = "".join(rowOut) > > > > 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 = "".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. :-) There are multiple datatypes typically varchar,number,date and sometimes raw and long. > > So I'm looking at anything that could help speed things up (it's quite possible 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 complexity of "format_col()" > and > > hence CPU cost. > > > > BTW I've actually put the process_the_row and format_col() code in-line as 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. > > > > 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. :-) No worries, I can wait. Thanks again, Chris > > > 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 context is: > > > > > > > > 1) Retrieve rows from source table and insert into a target table which has exactly the > same > > > > structure. > > > > > > > > 2) Retrieve rows from source table, add some column formatting and write 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=7393&alloc_id=16281&op=click > > > > _______________________________________________ > > > > 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_id344&op=click > > > _______________________________________________ > > > cx-oracle-users mailing list > > > cx-...@li... > > > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > > > > > > __________________________________ > > 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=7412&alloc_id=16344&op=click > > _______________________________________________ > > 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_id344&op=click > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > __________________________________ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail |