mysql同时读取写入,从数据库读取,同时写入另一个数据库

I am working on a simple script to read from one database (oracle) and

write to another (postgresql). I retrieve the data from oracle in

chunks and drop the data to postgresql continuously. The author of one

of the python database clients mentioned that using one thread to

retrieve the data from the oracle database and another to insert the

data into postgresql with something like a pipe between the two threads

might make sense, keeping both IO streams busy. Any hints on how to

get started?

Thanks,

Sean

解决方案Sean Davis wrote:

The author of one of the python database clients mentioned that

using one thread to retrieve the data from the oracle database and

another to insert the data into postgresql with something like a

pipe between the two threads might make sense, keeping both IO

streams busy.

IMHO he''s wrong. Network interaction is quite slow compared with CPU

performance, so there''s no gain (maybe even overhead due to thread

management and locking stuff). That''s true even on multiprocessor

machines, not only because there''s almost nothing to compute but

only IO traffic. CMIIW.

Using multiplexing, you''ll get good results with simple code without

the danger of deadlocks. Have a look at asyncore (standard library)

or the Twisted framework -- personally, I prefer the latter.

Regards,

Bj?rn

--

BOFH excuse #194:

We only support a 1200 bps connection.

Bjoern Schliessmann wrote:

Sean Davis wrote:

>The author of one of the python database clients mentioned that

using one thread to retrieve the data from the oracle database and

another to insert the data into postgresql with something like a

pipe between the two threads might make sense, keeping both IO

streams busy.

IMHO he''s wrong. Network interaction is quite slow compared with CPU

performance, so there''s no gain (maybe even overhead due to thread

management and locking stuff). That''s true even on multiprocessor

machines, not only because there''s almost nothing to compute but

only IO traffic. CMIIW.

Using multiplexing, you''ll get good results with simple code without

the danger of deadlocks. Have a look at asyncore (standard library)

or the Twisted framework -- personally, I prefer the latter.

Regards,

Bj??rn

Sean you can''t win - everyone has a different idea! You need to explain

that oracle has millions of records and it''s possible to a pipe open to

feed the Postgres side.

One thing I didn''t get - is this a one time transfer or something that is

going to happen often.

One time transfer live to the time issue.

Johnf

Bjoern Schliessmann a écrit :

Sean Davis wrote:

>The author of one of the python database clients mentioned that

using one thread to retrieve the data from the oracle database and

another to insert the data into postgresql with something like a

pipe between the two threads might make sense, keeping both IO

streams busy.

IMHO he''s wrong. Network interaction is quite slow compared with CPU

performance, so there''s no gain (maybe even overhead due to thread

management and locking stuff). That''s true even on multiprocessor

machines, not only because there''s almost nothing to compute but

only IO traffic. CMIIW.

Not so sure, there is low CPU in the Python script, but there may be

CPU+disk activity on the database sides [with cache management and other

optimizations on disk access].

So, with a reader thread and a writer thread, he can have a select on a

database performed in parallel with an insert on the other database.

After, he must know if the two databases use same disks, same

controller, same host... or not.

But, if its only a do-once job, maybe the optimization is net really

necessary.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值