December 24, 2010 at 12:18 pm
Hi,
I found out that a table in a production database is too large (23GB) and I wanted to delete some date from it. It contains data from 2001 -2010 and has 23 million rows. When I try to do a select * ...the sql server hangs (not responding)...or hte query goes on and on.
When I go into the table and select indexes reorganize or rebuild or update statisitics, then also the sql server hangs (not responding).
How can I delete some unuseful rows(2001-2009).
Any alternatives?
Regards,
Sushant
Regards
Sushant Kumar
MCTS,MCP
December 24, 2010 at 1:21 pm
It would be of assistance to those who wish to help if you can you post the table definition, and all indexes on that table, a limited amount of data which is representative of the data you desire to delete as well as the T-SQL statement you used in your attempts to delete unwanted rows, along with that statement's estimated execution plan.
Further questions:
1. Is your estimate of the number of rows that you are attempting to delete, is it 10 percent, 20 percent, 50 percent or greater than the total number of rows in the table?
2. Have you attempted to insert the number of rows which are to be retained into a new table, dropping the old table and then renaming the new table with the old table's name. (Be sure to have a valid backup before attempting this on a production database.)
3. Have you considered perfoming batch deletes? Refer to:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=91179
to see sample code for batchhing deletes.
December 24, 2010 at 1:23 pm
Are you trying to rebuild the indexes through the GUI ? You will have better performance if you script out the code, then run it as a job. You might want to put t-log backups in between some of the rebuilds to manage log growth. And 23G isn't huge. I have one that's about 600G in a 1.2T database
December 24, 2010 at 1:58 pm
Why you are trying to SELECT all the records!?
While you are using the SQL Server 2005 you have possibility to do the partition table ...
December 24, 2010 at 2:44 pm
Please provide the schema, all indexes and the select that is hanging.
I have databases with tables much greater than this and do not have issues.
Steve Jimmo
Sr DBA
“If we ever forget that we are One Nation Under God, then we will be a Nation gone under." - Ronald Reagan
December 24, 2010 at 4:11 pm
I agree with the others. Knowing structure and queries in use for this will go miles in helping to resolve it.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
December 24, 2010 at 8:08 pm
SKYBVI (12/24/2010)
Hi,I found out that a table in a production database is too large (23GB) and I wanted to delete some date from it. It contains data from 2001 -2010 and has 23 million rows. When I try to do a select * ...the sql server hangs (not responding)...or hte query goes on and on.
When I go into the table and select indexes reorganize or rebuild or update statisitics, then also the sql server hangs (not responding).
How can I delete some unuseful rows(2001-2009).
Any alternatives?
Regards,
Sushant
Have you ever actually previously done any database maintenance and integrity checks on this database?
--Jeff Moden
Change is inevitable... Change for the better is not.
December 31, 2010 at 8:11 am
I successfully deleted the unuseful rows from the table.
I used sp_spacesused 'tablename' to see how much space was freed up , and it was 10 gb.
The earlier size (of database) was 28 GB and now it should be around 18 GB.
But when I see, the mdf file is 28 GB now also.
I tried to go into dbname -->prop--> initial size was 28 gb, i changed it into 18 gb.
But it didnt change, it again came back to 28 gb..
The whole purpose of deleting the unuseful rows was free up some space, which is not acheived..
How can it be done??
HAPPY NEW YEAR
Regards,
Sushant
DBA
West Indies.
Regards
Sushant Kumar
MCTS,MCP
December 31, 2010 at 8:16 am
Is there any way other than shrinking??
as I want to avoid it.
HAPPY NEW YEAR AHEAD.
Regards,
Sushant
DBA
West Indies
Regards
Sushant Kumar
MCTS,MCP
December 31, 2010 at 8:35 am
SKYBVI (12/31/2010)
The whole purpose of deleting the unuseful rows was free up some space, which is not acheived..
You have freed up space. You've freed up space within the data file for SQL to reuse. If you want some of that space released to the file system, you need to shrink the data file. Don't forget to rebuild indexes after.
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
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply