Re: : CLOB performance issue

Vladimir Ryabtsev <[email protected]>
Newsgroups gmane.comp.python.db.cx-oracle
Message-ID <CAMqTPqk-Pk+V6bFAw3qxFFqaKe994TNcSJvb1DHz7AMt-sNSvA@mail.gmail.com>
Hello avinash,

Very weird workaround but it is really solution! It works 60% faster than
my variant. Thanks.

But it seems, in general, this way has some disadvantages:
- you must be able to select just inserted records fast (i.e. you must have
indexes) otherwise performance advantage will be lost;
- extra locks on table records;
- more complex logic of program.

Although this points may not be essential, this is actually a sort of trick
trick and I believe authors should somehow fix the library to make it usage
more straighforward.


2014-07-18 13:06 GMT+04:00 avinash nandakumar <[email protected]
>:

> There is another way to insert data into the table which does not require
> you to call setvalue().
> The way is first you insert an empty CLOB into the table. Then you fetch
> the CLOB variable for update and write data into the CLOB.
> I can see better performance in this case.
> I have demonstrated the usage below:-
>
> *#create table  table_clob ( msg_id number, message CLOB)*
>
> *import cx_Oracle*
> *import time*
> *con = cx_Oracle.connect("scott/tiger@inst1")*
>
> *num_records = 100*
> *cur = con.cursor()*
> *text = '*
> **2**20*
> *rows =[]*
>
> *start_time = time.time()*
>
> *for id in range(num_records):*
> *    rows.append([id+1])*
>
> *cur.bindarraysize = num_records*
> *cur.executemany("insert into table_clob (msg_id, message) values (:1,
> empty_clob())", rows)*
>
> *selstmt = "select message from table_clob where msg_id between 1 AND :1
> for update"*
> *cur.execute(selstmt, [num_records])*
> *for id in range(num_records):*
> *    results = cur.fetchone()*
> *    results[0].write(text)*
>
> *con.commit()*
>
> *end_time =  time.time()*
> *print end_time -start_time*
> *cur.close()*
> *con.close()*

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds

_______________________________________________
cx-oracle-users mailing list
cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/cx-oracle-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.