473,848 Members | 1,559 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading Huge Text File Problem

Hi,

I am trying to read a huge text file (2GB) using
StreamReader.

I do this:
Read a line (readline())
I process the line a bit (split it with delimeter and
change fields a bit)
execute (using transaction) a insert query to Ms Sql server
Commit a transaction for 1000 insert queries.

For the first 10000 records speed is pretty good.However
speed gradually slows down significally ever after.What's
wrong?Do i have to use a buffer size in streamreader's
constructor?Do i have to use filestream instead? Is it Sql
server or disk performance problem ?

Thanx!
Nov 20 '05 #1
5 3417
Are you building a concatenated string? If so, using the StringBuilder class
clould improve the speed.

Just an idea...

--
Greetz,
Jan
_______________ _______________ ____
Read my weblog: http://weblogs.asp.net/jan
"WoodenSwor d" <an*******@disc ussions.microso ft.com> schreef in bericht
news:e2******** *************** *****@phx.gbl.. .
Hi,

I am trying to read a huge text file (2GB) using
StreamReader.

I do this:
Read a line (readline())
I process the line a bit (split it with delimeter and
change fields a bit)
execute (using transaction) a insert query to Ms Sql server
Commit a transaction for 1000 insert queries.

For the first 10000 records speed is pretty good.However
speed gradually slows down significally ever after.What's
wrong?Do i have to use a buffer size in streamreader's
constructor?Do i have to use filestream instead? Is it Sql
server or disk performance problem ?

Thanx!

Nov 20 '05 #2
Cor
Hi WoodenSword,

I seldom say this, but I think this is typicaly a question for or a SQL
newsgroup.

Or the very active microsoft.publi c.dotnet.framew ork.AdoNet newsgroup

Or do you think that it is inside your VB.net code.

In that case we should have to see some code from you, to help you I think?

Cor
I am trying to read a huge text file (2GB) using
StreamReader.

I do this:
Read a line (readline())
I process the line a bit (split it with delimeter and
change fields a bit)
execute (using transaction) a insert query to Ms Sql server
Commit a transaction for 1000 insert queries.

For the first 10000 records speed is pretty good.However
speed gradually slows down significally ever after.What's
wrong?Do i have to use a buffer size in streamreader's
constructor?Do i have to use filestream instead? Is it Sql
server or disk performance problem ?

Nov 20 '05 #3
* "WoodenSwor d" <an*******@disc ussions.microso ft.com> scripsit:
I am trying to read a huge text file (2GB) using
StreamReader.

I do this:
Read a line (readline())
I process the line a bit (split it with delimeter and
change fields a bit)
execute (using transaction) a insert query to Ms Sql server
Commit a transaction for 1000 insert queries.

For the first 10000 records speed is pretty good.However
speed gradually slows down significally ever after.What's
wrong?Do i have to use a buffer size in streamreader's
constructor?Do i have to use filestream instead? Is it Sql
server or disk performance problem ?


Post your code. Maybe you don't dispose unused objects and the
application runs out of memory.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Is the database set to Automatically Grow File?

Is the initial database free space adequate to handle all of the inserts or
is the SQL server having to pause, grow the database, insert some more
records, pause, grow the database....
"WoodenSwor d" <an*******@disc ussions.microso ft.com> wrote in message
news:e2******** *************** *****@phx.gbl.. .
Hi,

I am trying to read a huge text file (2GB) using
StreamReader.

I do this:
Read a line (readline())
I process the line a bit (split it with delimeter and
change fields a bit)
execute (using transaction) a insert query to Ms Sql server
Commit a transaction for 1000 insert queries.

For the first 10000 records speed is pretty good.However
speed gradually slows down significally ever after.What's
wrong?Do i have to use a buffer size in streamreader's
constructor?Do i have to use filestream instead? Is it Sql
server or disk performance problem ?

Thanx!

Nov 20 '05 #5
You should comment out the database part and just do the file reading,
parsing piece to see if it is the file stream stuff or the database code.

Break it down into smaller chunks to focus on where the problem is.

Jerry

"WoodenSwor d" <an*******@disc ussions.microso ft.com> wrote in message
news:e2******** *************** *****@phx.gbl.. .
Hi,

I am trying to read a huge text file (2GB) using
StreamReader.

I do this:
Read a line (readline())
I process the line a bit (split it with delimeter and
change fields a bit)
execute (using transaction) a insert query to Ms Sql server
Commit a transaction for 1000 insert queries.

For the first 10000 records speed is pretty good.However
speed gradually slows down significally ever after.What's
wrong?Do i have to use a buffer size in streamreader's
constructor?Do i have to use filestream instead? Is it Sql
server or disk performance problem ?

Thanx!

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2574
by: Michel de Becdelièvre | last post by:
I have some *performance* trouble reading MathML files in my application (in ASP.Net). - I have small MathML files (2-3k) as input - as (almost) all MathML files these use entities. I have no way to restrict the entities used. - to read an XML file entities into a document, you need to use a DTD, or you get an exception (any other way ?) - The MathML DTD is HUGE (2400+ Entities, ~300k of files), loading it in a document is a big CPU...
2
2502
by: Sabin Finateanu | last post by:
Hi I'm having problem reading a file from my program and I think it's from a procedure I'm using but I don't see where I'm going wrong. Here is the code: public bool AllowUsage() { OperatingSystem os = Environment.OSVersion; AppDomain ad = Thread.GetDomain();
16
2421
by: Christine | last post by:
I was wondering if it is possible to read in a text file as a data type other than string. I would like to read it in as some type that handles numbers, like double, or float.
9
35325
by: haibhoang | last post by:
I have a Windows Service that is trying to parse a large (> 1Gig) text file. I am keep getting OutOfMemoryException exception. Here is the code that's having problem: using (StreamReader streamReader = new StreamReader(stream, Encoding.ASCII)) { string line = ""; DateTime currentDate = DateTime.Now.Date; while (streamReader.Peek() > -1)
6
1872
by: Adrian Lin | last post by:
Is there a way to read a specfic line in a text file? For instance if I wanted to just read the 5th line is that possible without having to step through the other lines? Essentially I am doing huge calculations in which genetic matrices are saved in text files instead of being held in arrays that take up memory. I am trying to do something where the genetic matrix is stored in a text file and I call specfic lines for calculations then put...
21
6404
by: EdUarDo | last post by:
Hi all, I'm not a newbie with C, but I don't use it since more than 5 years... I'm trying to read a text file which has doubles in it: 1.0 1.1 1.2 1.3 1.4 2.0 2.1 2.2 2.3 2.4 I'm doing this (it's only a test trying to achieve the goal...):
16
15578
by: WATYF | last post by:
Hi there... I have a huge text file that needs to be processed. At the moment, I'm loading it into memory in small chunks (x amount of lines) and processing it that way. I'd like the process to be faster, so I'd like to try creating multiple threads, and having them load different chunks of the file at the same time and process it asynchronously. Is it possible to do something like that, and if so, what would be needed to do so?
3
2170
by: Ahmad Jalil Qarshi | last post by:
Hi, I have a text file having size about 2 GB. The text file format is like: Numeric valueAlphaNumeric values Numeric valueAlphaNumeric values Numeric valueAlphaNumeric values For example consider following chunk of actual data:
5
705
by: Luis Zarrabeitia | last post by:
I have a problem with this piece of code: ==== import sys for line in sys.stdin: print "You said!", line ==== Namely, it seems that the stdin buffers the input, so there is no reply until a huge amount of text has bin written. The iterator returned by xreadlines
0
10997
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10661
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10347
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7067
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5731
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5917
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4134
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3172
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.