How to select query of 13000001 no. of rows

  • On running select query of 13000001 no. of rows the error is:

    An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown.

    Thanks

  • Your client application doesn't have enough memory to hold all of those rows. This is not a database engine error

    What are you trying to do that requires 13 million rows.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • This is my test DB.To do anything.

    Thanks

  • Then get more memory on your client machine.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • You're prolly trying to execute the query in SSMS. Set your output to a file, then execute.

  • Thanks Jason I have alraedy applied it.

    Thanks

  • Bear in mind that if you run query output to file you'll have to go and open the file to see the results, and the app you use to read the file may well run out of memory itself.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • The file size is around 1.12 Gb and it is notepad file.

    When it opens my system is becoming slow.

    Thanks

  • Of course it will be slow. That is a lot of data!

    As Gail stated, your client app will also most likely puke. Why do you need to return all rows?

    -

    Jason

  • forsqlserver (5/31/2011)


    The file size is around 1.12 Gb and it is notepad file.

    When it opens my system is becoming slow.

    try using textmate to open it.

    but as other have said, do you really need that many rows?

  • forsqlserver (5/31/2011)


    The file size is around 1.12 Gb and it is notepad file.

    When it opens my system is becoming slow.

    Well..... yes.

    How much memory does your client machine have? I struggle with > 1GB of data on a laptop with 3GB of memory.

    This is purely a client machine hardware issue. If you want, for whatever reason, to load millions of rows of data into memory, you need the hardware to handle it.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I wonder if you ever taught any of my developers? < grin >

    [font="Comic Sans MS"]The GrumpyOldDBA[/font]
    www.grumpyolddba.co.uk
    http://sqlblogcasts.com/blogs/grumpyolddba/

  • Thanks Gail, I have already said this is my test DB,I have 2 GB RAM ...

    Thanks

  • forsqlserver (5/31/2011)


    Thanks Gail, I have already said this is my test DB,I have 2 GB RAM ...

    Dude simple math. You have 2 GB or ram. Most likely all of it already used by the OS ans sql server.

    You want to put another 1.2 GB in ram.

    2-2-1.2 = FAILURE.

    The end, goodbye. Buy more ram or find another way to see this data where you don't open 1.9 gazillion rows.

  • forsqlserver (5/31/2011)


    Thanks Gail, I have already said this is my test DB,I have 2 GB RAM ...

    That it's your test DB is irrelevant. You do not have enough memory on your machine to do what you're trying. Buy more memory or select less data. Seriously, why do you need 13 million rows for anything/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 15 posts - 1 through 15 (of 24 total)

You must be logged in to reply to this topic. Login to reply