0

I'm trying to write an XML file, which is a Google Product feed, but it's very slow.

Having done quite a bit of Googling, I am not sure of the fastest approach, except for breaking it into smaller files.

I have about 3500 products currently, and this is what I am doing.

Dim fs As New FileStream(HttpContext.Current.Server.MapPath("LOCATION OF FEED XML"), FileMode.Create)
Dim writer As New XmlTextWriter(fs, System.Text.Encoding.UTF8)

writer.WriteStartDocument()
   ' ==== LOAD DATABASE INTO OdbcDataReader CALLED 'd' ==== '
While d.Read
   try
        writer.WriteStartElement("item")

        writer.WriteStartElement("g:id")
        writer.WriteString(pID)
        writer.WriteEndElement()
        '==== etc 
    catch
        ignore broken ones
    end
End While

     writer.WriteEndElement()
     writer.WriteEndDocument()
     writer.Close()

 d.Dispose()
 connection.Dispose()
 connection.Close()

I am not familiar with FileStream, MemoryStream etc, so not really sure what is exactly happening here where the writing is concerned.

Presumably writing to memory would be faster, but what's the process to do that and then save to disk?

Would the amount of data be an issue for memory?

Obviously I am coding with VB, using .NET 2.0

Any suggestions appreciated.

4

1 に答える 1

0

パフォーマンスの問題は書き込みにあるようには見えませんが、パフォーマンスの低下の原因は読み取りにあるようです。どこからデータを読んでいますか?データベース?それがパフォーマンスのボトルネックです。

于 2012-07-09T14:13:43.280 に答える