Re: Insert Statement Bloating Log

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Louis Davidson (dr_dontspamme_sql_at_hotmail.com)
Date: 01/18/05


Date: Tue, 18 Jan 2005 16:23:41 -0600

Yeah, I am not sure that anyone can help you any better without better
details, which would be very hard to give over the newsgroups like this.

-- 
----------------------------------------------------------------------------
Louis Davidson - drsql@hotmail.com
SQL Server MVP
Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design - 
http://www.apress.com/book/bookDisplay.html?bID=266
Note: Please reply to the newsgroups only unless you are interested in 
consulting services.  All other replies may be ignored :)
"David R" <nospam@nospam.com> wrote in message 
news:4D353B22-35F6-4AF9-BC00-EA0189A134BB@microsoft.com...
> Hi Louis,
> Thanks for your'e time.
> I already broke it down to smaller chunks. That's the workaround I'm using
> now, I do a few small chunks then I truncate the log and do another set of
> small chunks. But I would really like to do it all at once, and to 
> understand
> why the log gets so overblown. I guess the only get to the root of this
> problem is to use Log Explorer from Lugiment but that's a bit pricey.
>
> David.
>
> "Louis Davidson" wrote:
>
>> Can you segment your inserts into smaller chunks?  This will alleviate 
>> some
>> of the problem.  Like 20 10000 row inserts?  Or something smaller?  The
>> larger the operation the more painful it can become.  No comfort I 
>> suppose,
>> but if you can do this pretty easily it might help quite a bit.
>>
>> (sorry I didn't see your earlier posts about checking the result set, my
>> bad.)
>>
>> -- 
>> ----------------------------------------------------------------------------
>> Louis Davidson - drsql@hotmail.com
>> SQL Server MVP
>>
>> Compass Technology Management - www.compass.net
>> Pro SQL Server 2000 Database Design -
>> http://www.apress.com/book/bookDisplay.html?bID=266
>> Note: Please reply to the newsgroups only unless you are interested in
>> consulting services.  All other replies may be ignored :)
>>
>> "David R" <nospam@nospam.com> wrote in message
>> news:F7D5BCE3-B3B8-467A-8626-2C44F0FA706A@microsoft.com...
>> >I already tried that. It returns < 200,000.
>> > Thanks,
>> > David
>> >
>> > "Louis Davidson" wrote:
>> >
>> >> Yeah, and have you checked to output of the select statement to be
>> >> certain
>> >> of the data you are trying to insert.  Try doing:
>> >>
>> >> select count(*)
>> >> from --the rest of your query.
>> >>
>> >> I have occasionally missed some criteria in larger joins like this 
>> >> that
>> >> aren't always easy to see.
>> >>
>> >> -- 
>> >> ----------------------------------------------------------------------------
>> >> Louis Davidson - drsql@hotmail.com
>> >> SQL Server MVP
>> >>
>> >> Compass Technology Management - www.compass.net
>> >> Pro SQL Server 2000 Database Design -
>> >> http://www.apress.com/book/bookDisplay.html?bID=266
>> >> Note: Please reply to the newsgroups only unless you are interested in
>> >> consulting services.  All other replies may be ignored :)
>> >>
>> >> "Alejandro Mesa" <AlejandroMesa@discussions.microsoft.com> wrote in
>> >> message
>> >> news:6F3A71C2-9DD7-482D-9164-7AEF6B677A06@microsoft.com...
>> >> > Are you using INSERT INTO ... SELECT ... or SELECT ... INTO ...?
>> >> >
>> >> >
>> >> >
>> >> > AMB
>> >> >
>> >> > "David R" wrote:
>> >> >
>> >> >> Hi Mike,
>> >> >> Thanks for your answer.
>> >> >> My table is a heap (nonclustered) and does not have any indexes at 
>> >> >> all
>> >> >> as
>> >> >> it was a table created for a one time research.
>> >> >> Do you have any other ideas?
>> >> >> Thanks,
>> >> >> David
>> >> >>
>> >> >> Here is the DDL
>> >> >> CREATE TABLE [MyTable] (
>> >> >> ColumnA char (8),
>> >> >> ColumnB varchar (10) ,
>> >> >> ColumnC varchar (50) ,
>> >> >> ColumnD char (10),
>> >> >> ColumnE varchar (4000) ,
>> >> >> ColumnF char (10) ,
>> >> >> ColumnG varchar (255),
>> >> >> ColumnH char (10) ,
>> >> >> ColumnI char (10) ,
>> >> >> ColumnJ varchar (25) ,
>> >> >> ColumnK varchar (25)
>> >> >> ) ON [PRIMARY]
>> >> >>
>> >> >>
>> >> >>
>> >> >> "Mike Epprecht (SQL MVP)" wrote:
>> >> >>
>> >> >> > Hi
>> >> >> >
>> >> >> > Please post the DDL and DML.
>> >> >> >
>> >> >> > In theory, if each row was on it's own page, the data portion 
>> >> >> > would
>> >> >> > be
>> >> >> > 1.6Gb
>> >> >> > in size. Then add overhead for indexes.
>> >> >> >
>> >> >> > Check that your query really retuns only 200'000 rows. What can
>> >> >> > really
>> >> >> > bloat
>> >> >> > an operation is page splits as they are fully logged. Use an 
>> >> >> > order
>> >> >> > by
>> >> >> > clause
>> >> >> > in your select that matches the clustered index on the 
>> >> >> > destination
>> >> >> > table.
>> >> >> > This will result in the data bieng written in a manner that
>> >> >> > eliminates
>> >> >> > page
>> >> >> > splits.
>> >> >> >
>> >> >> > Regards
>> >> >> > Mike
>> >> >> >
>> >> >> > "David R" wrote:
>> >> >> >
>> >> >> > > I have an Insert statement that gets data from 8 joined tables.
>> >> >> > > The
>> >> >> > > actual
>> >> >> > > result set has about 200,000 records in 11 char/varchar columns
>> >> >> > > according to
>> >> >> > > my calculations this result set should be less than 1 GB. But 
>> >> >> > > when
>> >> >> > > I
>> >> >> > > execute
>> >> >> > > this query the log file grows to over 80 GB!  Then I get the
>> >> >> > > following error
>> >> >> > > Server: Msg 1105, Level 17, State 2, Line 5
>> >> >> > > Could not allocate space for object 'MyTable' in database 
>> >> >> > > 'MyDB'
>> >> >> > > because the
>> >> >> > > 'PRIMARY' filegroup is full.
>> >> >> > > It looks like all the data that SQL Server used in the FROM 
>> >> >> > > clause
>> >> >> > > is
>> >> >> > > also
>> >> >> > > being logged and even then 80 GB sounds too high to me.
>> >> >> > > Does anyone have an idea what causes this behavior and how I 
>> >> >> > > can
>> >> >> > > stop
>> >> >> > > this
>> >> >> > > from happening?
>> >> >> > > Thanks,
>> >> >> > > David
>> >>
>> >>
>> >>
>>
>>
>> 


Relevant Pages

  • Re: delete issues with ado
    ... Look for newsgroups with either the ... >> all of the data off of the sql server in the database into a Dataset. ... The updateTable web service exception gets thrown. ...
    (microsoft.public.vb.database.ado)
  • Re: Creating unique Index
    ... with schemabinding --indexes on views require schemabinding ... Pro SQL Server 2000 Database Design - ... Please reply to the newsgroups only unless you are interested in ... > SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Numbering records in query
    ... suggesting to close the newsgroups? ... I suggest that you open books first:) ... This is why "SELECT a,b,c FROM Foobar" is the same query as ... This is MS SQL Server newsgroup and my questions are about SQL Server, ...
    (microsoft.public.sqlserver.programming)
  • Re: Convert Oracle create index to SQLServer
    ... and indexing it is IMO quite a big workaround to ... Louis Davidson wrote: ... Please reply to the newsgroups only unless you are ...
    (microsoft.public.sqlserver.programming)
  • Re: HELP! SQL Query Question
    ... people who know SQL Server best. ... Newsgroups are here to help peoplelike me. ... "Joe Celko" wrote: ... > Here is a quick kludge that will run like glue as the table gets larger. ...
    (microsoft.public.sqlserver.programming)