Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listing more than 10 million records from Oracle With C#

I have a database that contains more than 100 million records. I am running a query that contains more than 10 million records. This process takes too much time so i need to shorten this time. I want to save my obtained record list as a csv file. How can I do it as quickly and optimum as possible? Looking forward your suggestions. Thanks.

like image 436
sinanakyazici Avatar asked Nov 30 '11 09:11

sinanakyazici


1 Answers

I'm assuming that your query is already constrained to the rows/columns you need, and makes good use of indexing.

At that scale, the only critical thing is that you don't try to load it all into memory at once; so forget about things like DataTable, and most full-fat ORMs (which typically try to associate rows with an identity-manager and/or change-manager). You would have to use either the raw IDataReader (from DbCommand.ExecuteReader), or any API that builds a non-buffered iterator on top of that (there are several; I'm biased towards dapper). For the purposes of writing CSV, the raw data-reader is probably fine.

Beyond that: you can't make it go much faster, since you are bandwidth constrained. The only way you can get it faster is to create the CSV file at the database server, so that there is no network overhead.

like image 172
Marc Gravell Avatar answered Oct 21 '22 08:10

Marc Gravell