Fox DB相对于MySQL DB的插入时间 [英] Time for insertion Fox DB v.s MySQL DB

查看:64
本文介绍了Fox DB相对于MySQL DB的插入时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个C#应用程序,可将数据插入MySQL服务器并
我在Fox 9中有一个应用程序,可以使用Fox DB引擎插入相同的数据.

* C#应用程序的时间比狐狸应用程序的时间长得多(2000秒)比(5秒)
*狐狸繁殖的时间非常快(5秒)

为什么? :confused:
如何减少将数据插入MySQL DB的时间.

我使用的数据文件功能:

1)类型:csv
2)大小:900 KB
3)记录数:9000

在此先感谢!

Hello everybody,

I have a C# aplication that inserts data into MySQL server and
I have an application in Fox 9 that inserts the same data with Fox DB engine.

* The time for the c# application is very much longer than for the fox application (2000 seconds) vs (5 seconds)
* The time in the fox aplication is very quick (5 sec)

Why is that so? :confused:
How I can reduce the time to insert the data into MySQL DB.

Features of data file I use:

1) type: csv
2) size: 900 KB
3) number of records: 9000

Thanks in advance!

推荐答案

您需要考虑几件事.
1. Fox 9应用程序可能正在使用本地数据库,而不是通过TCP连接与MySQL数据库进行通信的C#应用​​程序.


2.您的C#应用​​程序中的每个插入操作是否都获得一个新的sql连接?如果您不使用连接池,那将大大降低速度.


3. MySql DB可能比Fox DB引擎要做更多的工作:检查列约束,索引更新,触发器等.


这将我们带到:


4.工作多线程,并说有20个线程在池中.从文件中读取项目时,将获得一个可用的工作程序线程,并使其处理数据库中的内容.当文件读取线程的可用工作线程用完时,您需要等待一个线程可用.当工作线程完成工作时,它将自己放回到可用工作线程的队列中.通过让更多线程并行执行DB任务,可以更快地完成工作,因为等待IO(往返MySQL服务器)的完成会浪费大量时间.


问候,


Manfred
There are a couple of things you have to consider.
1. The Fox 9 application is probably working with a local DB as opposed to the C# application that communicates with MySQL DB over a TCP connection.


2. Are you getting a new sql connection for each insert operation in your C# application? That would slow down things considerably if you''re not using the connection pool.


3. MySql DB might have more work to do than the Fox DB engine: Checking column constraints, index updates, triggers etc.


Which brings us to:


4. Work multi threaded and have say 20 threads in pool. When an item was read from the file get an available worker thread and have it process the DB stuff. When the file reading thread runs out of available worker threads you wait unitl one comes available. When a worker thread has accomplished it work it puts itself back into the queue of available workers. By having more threads doing DB stuff in parallel will get the work done quicker because there is much time wasted by waiting for IO (to and from MySQL server) to be completed.


Regards,


Manfred


没有看到您的C#代码和您的databaase模式,除了发布WAG,我们无法为您提供帮助.您是否正在使用MySql数据库的存储过程?您的索引和键设置正确吗?将记录插入"到MtyySQL中只是将记录追加到受影响的表的末尾,因此2000秒似乎-荒谬.

您确实知道FoxPro是一个过时的数据库应用程序(例如Access),并且您不必真正做任何特别的事情就可以使它看起来很快速.毕竟不是9000条记录...


Without seeing your C# code AND your databaase schema, there''s no way we can help you, short of just posting a WAG. Are you using a stored procedure for the MySql database? Are your indexes and keys correctly setup? "Insert"ing a record into MtyySQL is simply appending the record to the end of the affected table, so 2000 seconds seems - well - absurd.

You do know that FoxPro is a dedecated database application, like Access, and that you don''t really have to do anything special for it to appear to be speedy. 9000 records ain''t no thang, after all...



这篇关于Fox DB相对于MySQL DB的插入时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆