Friday, March 30, 2012

Log not needed

In an unusual circumstance I face, there is a very large log created by the
importation of several million rows from another database. After importing,
the database will never change. As the original database is still
available, and the import could be re-run at any time from this, neither
logging nor backup is desirable. The whole thing can be recreated whenever
needed (the original from which the import is done is backed up).
This is for Express.
What facilities are available to either suppress the log or remove it? It
is several gigabytes long after the import.
As I understand it, SELECT queries to search the database will not create
any log, and it will never grow again. Right?
Tom EllisonWhat about a read only DB?
Lookup ALTER DATABASE (Transact-SQL) in BOL it is covered in that section
http://sqlservercode.blogspot.com/
"Tom Ellison" <tellison@.jcdoyle.com> wrote in message
news:eU7tOIgRGHA.2224@.TK2MSFTNGP10.phx.gbl...
> In an unusual circumstance I face, there is a very large log created by
> the importation of several million rows from another database. After
> importing, the database will never change. As the original database is
> still available, and the import could be re-run at any time from this,
> neither logging nor backup is desirable. The whole thing can be recreated
> whenever needed (the original from which the import is done is backed up).
> This is for Express.
> What facilities are available to either suppress the log or remove it? It
> is several gigabytes long after the import.
> As I understand it, SELECT queries to search the database will not create
> any log, and it will never grow again. Right?
> Tom Ellison
>
>|||Dear SQL:
In BOL "ALTER DATABASE/Transact SQL Reference":
READONLY
Specifies the filegroup is read-only. Updates to objects in it are not
allowed. The primary filegroup cannot be made read-only. Only users with
exclusive database access can mark a filegroup read-only.
My log is in the primary filegroup, right? Is there more to it than this?
Tom Ellison
"SQL" <sqlservercode@.gmail.com> wrote in message
news:u8IUAOgRGHA.4608@.tk2msftngp13.phx.gbl...
> What about a read only DB?
> Lookup ALTER DATABASE (Transact-SQL) in BOL it is covered in that section
> http://sqlservercode.blogspot.com/
>
> "Tom Ellison" <tellison@.jcdoyle.com> wrote in message
> news:eU7tOIgRGHA.2224@.TK2MSFTNGP10.phx.gbl...
>|||Would it not be possible and simple to shrink the log to nothing after the
initial import? It could then function normally, meaning nothing would
happen in ordinary operations, just searching the database.
Tom Ellison
"Tom Ellison" <tellison@.jcdoyle.com> wrote in message
news:eU7tOIgRGHA.2224@.TK2MSFTNGP10.phx.gbl...
> In an unusual circumstance I face, there is a very large log created by
> the importation of several million rows from another database. After
> importing, the database will never change. As the original database is
> still available, and the import could be re-run at any time from this,
> neither logging nor backup is desirable. The whole thing can be recreated
> whenever needed (the original from which the import is done is backed up).
> This is for Express.
> What facilities are available to either suppress the log or remove it? It
> is several gigabytes long after the import.
> As I understand it, SELECT queries to search the database will not create
> any log, and it will never grow again. Right?
> Tom Ellison
>
>|||Yes you could issue a BACKUP LOG (logname) WITH TRUNCATE_ONLY followed by a
DBCC SHRINKFILE command
http://sqlservercode.blogspot.com/
"Tom Ellison" <tellison@.jcdoyle.com> wrote in message
news:%232PoWZgRGHA.1780@.TK2MSFTNGP12.phx.gbl...
> Would it not be possible and simple to shrink the log to nothing after the
> initial import? It could then function normally, meaning nothing would
> happen in ordinary operations, just searching the database.
> Tom Ellison
> "Tom Ellison" <tellison@.jcdoyle.com> wrote in message
> news:eU7tOIgRGHA.2224@.TK2MSFTNGP10.phx.gbl...
>|||> My log is in the primary filegroup, right?
No, the log isn't in any file group. The file group concept is only for data
files.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Tom Ellison" <tellison@.jcdoyle.com> wrote in message news:Ou1avWgRGHA.1160@.TK2MSFTNGP09.ph
x.gbl...
> Dear SQL:
> In BOL "ALTER DATABASE/Transact SQL Reference":
> READONLY
> Specifies the filegroup is read-only. Updates to objects in it are not
> allowed. The primary filegroup cannot be made read-only. Only users with
> exclusive database access can mark a filegroup read-only.
> My log is in the primary filegroup, right? Is there more to it than this?
> Tom Ellison
>
> "SQL" <sqlservercode@.gmail.com> wrote in message
> news:u8IUAOgRGHA.4608@.tk2msftngp13.phx.gbl...
>|||I'd go for first simple recovery mode, then shrinking the log file after the
import (tips and hints
at http://www.karaszi.com/SQLServer/info_dont_shrink.asp). Then set the data
base (not filegroup) to
read-only.
Also, see if you can do the import minimally logged. Some import mechanisms
allow for this (BCP,.
BULK INSERT, DTS if you do it right etc).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Tom Ellison" <tellison@.jcdoyle.com> wrote in message news:eU7tOIgRGHA.2224@.TK2MSFTNGP10.ph
x.gbl...
> In an unusual circumstance I face, there is a very large log created by th
e importation of several
> million rows from another database. After importing, the database will ne
ver change. As the
> original database is still available, and the import could be re-run at an
y time from this,
> neither logging nor backup is desirable. The whole thing can be recreated
whenever needed (the
> original from which the import is done is backed up).
> This is for Express.
> What facilities are available to either suppress the log or remove it? It
is several gigabytes
> long after the import.
> As I understand it, SELECT queries to search the database will not create
any log, and it will
> never grow again. Right?
> Tom Ellison
>
>|||Dear Tibor:
Thank you very much.
Now, on site, we do not have tools for production. There is only SQL
Express and Access. The OS is not a server. Am I correct to rule out BCP
and DTS on this basis?
As the source is an Access MDB, I'm thinking BULK INSERT does not apply.
Can BULK INSERT be done from an mdb? If so, what parameters allow for this?
Assuming there may not be an extra 3 gigabytes of disk space on every
computer where we need to install this, it would be a good thing just not to
create this log.
What would it do if the log were on a NULL device?
Is there any hope?
Tom Ellison
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:evtXglgRGHA.5908@.TK2MSFTNGP14.phx.gbl...
> I'd go for first simple recovery mode, then shrinking the log file after
> the import (tips and hints at
> http://www.karaszi.com/SQLServer/info_dont_shrink.asp). Then set the
> database (not filegroup) to read-only.
> Also, see if you can do the import minimally logged. Some import
> mechanisms allow for this (BCP,. BULK INSERT, DTS if you do it right etc).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Tom Ellison" <tellison@.jcdoyle.com> wrote in message
> news:eU7tOIgRGHA.2224@.TK2MSFTNGP10.phx.gbl...
>|||Tom Ellison (tellison@.jcdoyle.com) writes:
> Now, on site, we do not have tools for production. There is only SQL
> Express and Access. The OS is not a server. Am I correct to rule out BCP
> and DTS on this basis?
DTS (or SSIS), yes, BCP no. BCP comes with SQL Server Express.

> As the source is an Access MDB, I'm thinking BULK INSERT does not apply.
> Can BULK INSERT be done from an mdb? If so, what parameters allow for
> this?
I don't know much about Access, but as Access, or rather Jet, is a
DB engine, an MDB file is likely to have more than data. I mean it
has things like index pointers etc. So the answer would be no.

> Assuming there may not be an extra 3 gigabytes of disk space on every
> computer where we need to install this, it would be a good thing just
> not to create this log.
> What would it do if the log were on a NULL device?
I seriously doubt that SQL Server would let you get away with it.
The first step is to set the database to simple recovery. In this mode,
SQL Server will truncate the log regularly. Since the log cannot be
truncated past the oldest open transaction, it can still become huge,
if your transactions are huge. To keep down the log size, you could import
data in batches, of, say, 1000 rows at a time. Bowever, this is more
complex, and the import will take longer time. (You don't say how you
run the import, but I assume that you run queries against a linked
server.)
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Dear Erland:
Thanks very much. Pretty much what I expected.
The initial installation step is to import about 10 million rows. This is
going to create a HUGE log file, for which we have no use. I doubt the 10
gigabytes will be available on the destination computers. Some are just
laptops.
We have just spent several hours investigating various problems this is
causing.
We are first defragmenting the hard drive. However, creating both database
and log are causing a fratmented database file. In addition, as I said,
there will likely not be enough space for both on the hard drive.
Right now we are using Access to append the rows to SQL Express. It is far
too slow. We drop the indexes ahead of time, append a few million records,
and recreate the indexes. It is taking hours to do this. I'd really like
to find a way to speed this. The best approach of which I know is to create
a linked server to the Access database. I've always done that before using
EM. When I use this in QA:
sp_addlinkedserver @.server = 'MyJet', @.srvproduct = '', @.provider =
'Microsoft.Jet.OLEDB.4.0',
@.datasrc = 'C:\Documents and Settings\All Users\Documents\TData.mdb'
I cannot then access the Jet table:
SELECT * FROM MyJet...TData
Server: Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "MyJet"
reported an error. Authentication failed.
Server: Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider
"Microsoft.Jet.OLEDB.4.0" for linked server "MyJet".
OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "MyJet" returned
message "Cannot start your application. The workgroup information file is
missing or opened exclusively by another user.".
I used the same script then to try to create the linked server in SQL 2000,
and it fails similarly. However, I then opened that SQL 2000 linked server
using EM and changed:
Linked Server Properties
Security
For a login not defined in the list above, connections will:
Be made without using a security context
Or course, EM doesn't work at all with Express, and it is only by solving
this in Express that it will accomplish anything toward my goals. I've also
tried to see what T-SQL EM is generating to do this, but with no success.
If I knew just what EM was doing, it might fix me up pretty quickly, right?
The SQL 2000 linked server then commenced working. I expect this relates to
setting one of the options in the linked server, but I have not been able to
isolate it.
If I could find how to fix my linked server within Express, then I am hoping
to see improved performance in the appending.
My goals are to improve this performance and to also prevent the creation of
a useless multi-gigabyte log, which may not fit within the available disk
space, and which horribly fragments the creation of the database. I may
just break down and size the database in advance.
Please make any recommendations that occur to you. And thank you very much,
again.
Tom Ellison
"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns97856F8AD31CYazorman@.127.0.0.1...
> Tom Ellison (tellison@.jcdoyle.com) writes:
> DTS (or SSIS), yes, BCP no. BCP comes with SQL Server Express.
>
> I don't know much about Access, but as Access, or rather Jet, is a
> DB engine, an MDB file is likely to have more than data. I mean it
> has things like index pointers etc. So the answer would be no.
>
> I seriously doubt that SQL Server would let you get away with it.
> The first step is to set the database to simple recovery. In this mode,
> SQL Server will truncate the log regularly. Since the log cannot be
> truncated past the oldest open transaction, it can still become huge,
> if your transactions are huge. To keep down the log size, you could import
> data in batches, of, say, 1000 rows at a time. Bowever, this is more
> complex, and the import will take longer time. (You don't say how you
> run the import, but I assume that you run queries against a linked
> server.)
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx

No comments:

Post a Comment