Thanks,
Sherif
Matthew Brown wrote:A couple of things you could try:
- Create the ArrayList with a specified capacity (there's a constructor that does that) big enough for what you need. That stops the ArrayList having to constantly reallocate a new internal array.
i tried this and the still the problem exits , but i noticed something when i'm using the Arraylist that the arrayLists were populated with around 55 records then stop for 3 to 5 mins then continue and so on till it's done !!
- Or, switch to a LinkedList, which is faster to modify in general than an ArrayList.
Either of those any help?
Thanks,
Sherif
Campbell Ritchie wrote:I am surprised by that. ArrayList guarantees amortised constant time for add() or similar. Agreed it is quicker to add to the middle of a LinkedList, but finding the nth element of a linked list runs in linear time. I suspect you only require a few seconds for adding 40000 elements to that List, and your delays are occurring elsewhere.
Thanks,
Sherif
Sherif Shehab wrote:i thought may be the delay from the query itself i tried it outside my code it was very fast , so i made a counter and i found it is incremented slowly it takes about nearly 15 mins to fill all the Arraylists with around 9000 records !
To test this theory, try removing the ArrayList, but looping through the ResultSet anyway (doing nothing with the results).
Thanks,
Sherif
Thanks,
Sherif
Sherif Shehab wrote:i tried it and found the delay from it , but what may cause this delay in the ResultSet ?
Thanks,
Sherif
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |