Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Speed

Speed

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasesysadminperformance
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mihksoft
    wrote on last edited by
    #1

    Hy I have a site on a host for ASP.NET. I have a file with 30000 records. I have a .mdf file with a table with 30000 records. Method 1 I read from file a record and diplay in a label. Label1.Text = File.ReadAllLines(Server.MapPath("~/fisier.txt"),Encoding.UTF8)[index]; Method 2 I read from .mdf file from my table the same record. Can tell me witch of the 2 method is faster? thx

    C G 2 Replies Last reply
    0
    • M mihksoft

      Hy I have a site on a host for ASP.NET. I have a file with 30000 records. I have a .mdf file with a table with 30000 records. Method 1 I read from file a record and diplay in a label. Label1.Text = File.ReadAllLines(Server.MapPath("~/fisier.txt"),Encoding.UTF8)[index]; Method 2 I read from .mdf file from my table the same record. Can tell me witch of the 2 method is faster? thx

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Probably the second, but both are a disaster, obviously. Well, readalllines returns a string[] as I recall, so it won't compile. ReadAllText is probably faster than the database solution, as it mindlessly reads and passes a single string. This does NOT mean that flat files are faster than databases.

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      1 Reply Last reply
      0
      • M mihksoft

        Hy I have a site on a host for ASP.NET. I have a file with 30000 records. I have a .mdf file with a table with 30000 records. Method 1 I read from file a record and diplay in a label. Label1.Text = File.ReadAllLines(Server.MapPath("~/fisier.txt"),Encoding.UTF8)[index]; Method 2 I read from .mdf file from my table the same record. Can tell me witch of the 2 method is faster? thx

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        Method 2 is by far the most efficient. A specific record in the table can be accessed directly without having to read all of them. The ReadAllLines method will read the entire file and create an array that contains 30000 string objects. The memory used for this will be approximately double the file size, plus 120 kB for the array object itself. A less wasteful method to read the file would be to use a StreamReader to read line by line until you reach the line you want. That will not create a huge array in memory, and you don't have to read the entire file.

        --- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups