Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load 1 milion records from database fast?

Now we have a firebird database with 1.000.000 that must be processed after ALL are loaded in RAM memory. To get all of those we must extract data using (select * first 1000 ...) for 8 hours. What is the solution for this?

like image 482
Leonard P. Avatar asked Apr 20 '10 17:04

Leonard P.


People also ask

How long does it take to query 1 million rows?

Counting 1 million rows in SQL server takes 1 minute - Database Administrators Stack Exchange.

Can MySQL handle 1 million records?

Can MySQL handle 100 million records? Yeah, it can handle billions of records. If you properly index tables, they fit in memory and your queries are written properly then it shouldn't be an issue.


2 Answers

Does each of your "select * first 1000" (as you described it) do a full table scan? Look at those queries, and make sure they are using an index.

like image 157
aaaa bbbb Avatar answered Sep 25 '22 02:09

aaaa bbbb


How long does it take to construct the DTO object that you are creating with each data read?

{ int a = read.GetInt32(0); int b = read.GetInt32(1); mylist.Add(new DTO(a,b)); }

You are creating a million of these objects. If it takes 29 milliseconds to create one DTO object, then that is going to take over 8 hours to complete.

like image 45
300 baud Avatar answered Sep 25 '22 02:09

300 baud