November 3, 2010 at 1:01 pm
Select * from a table with one billion rows failing with following error (SQL 2005 SP3 HF11)
An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown.
November 3, 2010 at 1:04 pm
RPSql (11/3/2010)
Select * from a table with one billion rows failing with following error (SQL 2005 SP3 HF11)An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown.
i'm not surprised; selecting that much data and trying to render it into a display (gridmode/textmode/etc) would make any GUI run out of memory.
what are you trying to actually do? why would you try to get all billion rows? what was your process going to do with them?
If you can explain that, we can probably suggest a better alternative.
Lowell
November 3, 2010 at 1:47 pm
Not to mention if some of the columns are blobs (image, text, etc). Why select *? You should only select the columns you actually need.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
November 3, 2010 at 1:50 pm
RPSql (11/3/2010)
Select * from a table with one billion rows failing with following error (SQL 2005 SP3 HF11)An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown.
Makes sense. What's your question?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
November 3, 2010 at 2:15 pm
note that even if the table with a billion rows had two columns, an ID and a varchar(30) for a name or something(38 bytes of data per row), you'd need 35+ gig of RAM / local harddrive space to download and then render the data.
/*--Results
Bytes KByes Megs Gigs
-------------- ---------------- -------------------- ----------------------
38000000000.0 37109375.000000 36239.6240234375000 35.3902578353881835937
*/
SELECT
--assuming just 38 bytes of data per row
(38.0 * 1000000000) AS Bytes,
(38.0 * 1000000000) / 1024 AS KByes,
(38.0 * 1000000000) / (1024.0 * 1024.0) AS Megs,
(38.0 * 1000000000) / (1024.0 * 1024.0 * 1024.0) AS Gigs
Lowell
November 3, 2010 at 2:30 pm
This is data releated and down to the size of the returned data grid. Is there a reason for want ALL the data from this table?
I've seen this a number of times when running sprocs in a loop which return a result or return value. I all cases to date, switching to text view in management studio has worked.
November 3, 2010 at 2:34 pm
Was the error thrown on the database server or on the client receiving the data? Was there an 'order by' on the select?
November 3, 2010 at 11:03 pm
RPSql (11/3/2010)
Select * from a table with one billion rows failing with following error (SQL 2005 SP3 HF11)An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown.
I don't think this is application/business specific query.
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
November 4, 2010 at 6:35 am
David Webb-200187 (11/3/2010)
Was the error thrown on the database server or on the client receiving the data? Was there an 'order by' on the select?
Honestly, does it matter whether there's an Order By or not?
There is not now, nor will there ever be, any reason for a human eye to look at 1-billion records at one time, and that query has no other possible use as written.
Even if the server were able to process the query, and the network were able to feed it to your workstation in finite time, and your workstation were able to render it, it would still be useless because it would take multiple lifetimes for a human eye and brain to do anything with it. If you spend an average of 0.1 second looking at each row, you'll be staring at it for over 3 years, without taking a break for sleep, food, or anything else. And 0.1 seconds isn't long enough to accomplish anything useful that a computer can't do better.
Which is why I started out by asking what the question was. Yes, there's an error, and the reason for the error is obvious, but there's been no statement yet of what the person was trying to accomplish. I'm hoping there's some result the original poster was trying to get besides 1-billion rows of data on their computer screen, and that we can help with solving that actual, underlying problem.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
November 4, 2010 at 6:42 am
This must be a pi$$ take
November 4, 2010 at 7:34 am
Carlton Leach (11/4/2010)
This must be a pi$$ take
Or a troll
This should fix the error:
Select top 100 * from table_with_one_billion_rows
Or get a bigger monitor 🙂
November 4, 2010 at 8:32 am
I was going to suggest this solution:
Select
*
from
table_with_one_billion_rows
cross join
table_with_one_billion_rows
November 4, 2010 at 8:40 am
or ask these guys to run the query for you
November 4, 2010 at 1:14 pm
homebrew01 (11/4/2010)
Carlton Leach (11/4/2010)
This must be a pi$$ takeOr a troll
I don't think so. I looked at the users previous posts (click on the user, select "Find all member's posts") and they look legitamate. Although they do appear to be a realy newbe.
Cheers
Leo
Leo
Nothing in life is ever so complicated that with a little work it can't be made more complicated.
November 4, 2010 at 1:31 pm
maybe he was doing a select * from BillionRowTable so he could see the column names, and the error threw him off.
He may not be familiar with sp_help [TableName] yet.
Lowell
Viewing 15 posts - 1 through 15 (of 23 total)
You must be logged in to reply to this topic. Login to reply