Showing posts with label back. Show all posts
Showing posts with label back. Show all posts

Tuesday, March 27, 2012

Database Snapshot

Need some help, i have some database snapshots files provided from an external source. Need to be able to understand how i get them back into a database format if possible.

Files for example are table1.bcp, table2.bcp with als a file called scheme.sql which sets up these tables in sql but does not populate them. Nothing else was provided except a .vcd file which i dont know whtat its for.

any clues?

Dan

This link describes how to restore a database from a database snapshot

http://www.sqlservercentral.com/columnists/akhosla/2733.asp

unfortunately I don't have right now access to an SQL server to see how to 'make' SQL Server 'see' a snapshot created by another server

|||

I dont have the original database though, only these files and this link assumes you have the original database?/

Dan

|||

yes this link assumes you made the snapshot on the same sql server :(

|||

Are you CERTAIN that these files were created using the SQL Server Database Snapshot feature?

It looks to me as if you have a SQL script to create tables, and BCP data files to feed into the BCP (Bulk copy) utility to load the data.

I would read BOL on BCP and attempt to load the files that way.

|||

Yes you are correct, this does indeed seem to be a Bulk Copy in Native format, guess i was going down the wrong path.

Thanks i now have the data in the correct format, also the extract works in SQL 2000 which is good.

Much appreciated.

Dan

Wednesday, March 21, 2012

database showing suspect

I moved a database file (.mdf) from the Microsoft SQL Server data directory to another location, and moved it back into the original location. After which the database staus changed to suspect.
How do I make it live? ThanksRead up on sp_resetstatus in the Books online.

Monday, March 19, 2012

Database Search Engine

Hi folks,
Whts up......? M back, after a long gap.
I have come across with a major issue. And u know wht th issue is.......?
It is about th DATABASE SEARCH TOOL. I have a database of around 30 tables. Now I wud like to have aa search engine on my .asp page. There will be a text box on th page and one submit button. After typing some text in th text area n submitting th page, my package sud check tht perticular text in all th COLUMNS of all th TABLES, n whrevr it gets a match (exactly same, or by speech recognition), it sud through th links on th next page.

Nw i wud like u guys to take this problem, at th earliest n come up with a up to th mark solution.

ThnkxYou will probably want to use SQL Server's full-text search capability.

But...

...you are going to allow web page viewers to issue non-sargable searches of every value of every column in every table in your database? That sounds insane to me. What kind of performance to you expect?|||Aside from the issues the blind dude mentions, I'm sure we've all "played' with this...

You need dynamic sql and a select against the information schema columns view...

EDIT: AND a cursor, AND a temp or table variable to hold the results...

what do you plan to do about dates and numbers?|||Oh come on! I understand the requirement is somewhat fishy, but this is not a homework where just the solution is needed! If you REALLY need to search for a pattern (even if it's exact) in every field of every table, - why would one want to use dynamic SQL or a cursor or a combination there of? Unless your intention is to kill the server with the second connection while the first one is still doing this insanity?

You'll need to write a function for all tables that will transpose all the char-based columns into one column with UNION ALL and a CAST to accomodate for the widest field and a WHERE clause for each participant of the UNION with the pattern that you're looking for. The second column should be a table identifier and possibly the third should be the PK from the table (I hope, contrary to "some" opinions that you're using INT/BIGINT for your PKs). Then you fire this function from the stored procedure that further manipulates the results. At THAT point, and at that point only, you may have to use dynamic SQL, and possibly a cursor, if the retrieval of the "links" will involve selection from the tables that appeared from the execution of the function mentioned above.

EDITED: And while writing the participants of the UNION, make sure to use either READ UNCOMMITTED isolation level, or NOLOCK table hint, UNLESS (!!!) DML operations that may be performed on the affected tables is important.|||I'm speechless....|||Well, that's ANOTHER way to skin the cat...

...but it's still going to scream bloody murder while you're peeling off the fur.|||Here's a sp I found you can get started with.|||Yup, ANOTHER way would be to implement Full-Text Search and use CONTAINSTABLE while UNIONed ALL 30 times. Either way it's a case of animal abuse ;)|||Yup, ANOTHER way would be to implement Full-Text Search and use CONTAINSTABLE while UNIONed ALL 30 times. Either way it's a case of animal abuse ;)Yeah, but as long as it is just a cat...

-PatP|||Well, that's ANOTHER way to skin the cat...

...but it's still going to scream bloody murder while you're peeling off the fur.

You crack me up.....|||Thnkx folks,
Thnkx for ur help. Though I hv'nt started th work suggested by u people.........as th week passed was tight. Lemme give a try n see what comes.

Thnkx 1nc again|||implement full text indexing on the columns that you wish to search
and use the following functions
contains, freetext, containstable and freetextable.
this is much better than like and dynamic sql because of the "Linguistic based search" ability of the fulltext service
to search long unstructured text in the where clause use freetext
to use the most powerfull and most focused of the 4 choose contains in the where clause (contains will find prefix terms , inflectional, generational and other forms of searches)
to search a table based result set use containstable or freetextable
the diff is that you place these in the from clause of your select.

good luck|||Check this site: http://vyaskn.tripod.com/search_all_columns_in_all_tables.htm

Sunday, March 11, 2012

Database Restore Woes

I attempt to back up a database on one server and restore it on my local machine.

This is what the query text looks like:

restore database model from
Disk='c:\JQJ\mydump\model.bak'
with replace

I get this error:

The backup of the system database on device c:\JQJ\mydump\model.bak cannot be restored because it was created by a
different version of the server
(134217922) than this server (134218488).

The other server product version is: 8.00.194(RTM)
The server on my machine is 8.00.760(SP3)

1.How can I make this restore work? Seems to me I have the later version, so I should be able to handle it. Mine is a
10-user, and the other is enterprise.

2.Also I need to be able to force a different path and even database name: The source server where I create the backup file
may have a different location than I have on my machine, so what parameters can I give the command so that it will use the
location I specifiy? The backup file will have the location information relative to the source server, which I can not
always use. This means I will need to programatically extract that location information on my machine. (I can't hard code
it, since other people with different installation setups will use my program on their machines).

3.The database name on the source server may be ABC, but I may want to restore over XYZ. How can I force that? Perhaps it
would be the same parameter I need for 2.

Thanks,

JonJon Jacobs (JonJacobsAtcomcast.net) writes:
> I attempt to back up a database on one server and restore it on my local
> machine.
> This is what the query text looks like:
> restore database model from
> Disk='c:\JQJ\mydump\model.bak'
> with replace
> I get this error:
> The backup of the system database on device c:\JQJ\mydump\model.bak
> cannot be restored because it was created by a different version of the
> server (134217922) than this server (134218488).
> The other server product version is: 8.00.194(RTM)
> The server on my machine is 8.00.760(SP3)
> 1.How can I make this restore work? Seems to me I have the later
> version, so I should be able to handle it. Mine is a 10-user, and the
> other is enterprise.

I would expect that it is possible to restore a backup from SQL 2000
RTM on SQL 2000 SP3, but it is very clear that it is not possible in
this case. But then again, you are not restoring any database - you
are restoring model. That's a system database, so I assume it is special.

Question: are you restoring model, because you really need a copy of model
from the other box on your machine? Or did you just pick model as a test
case? In the former case, the easiest may be to script any user objects
you have in model, and run the script. I would not really expect that
you have any data in model. If you are just testing, try Northwind or
pubs instead.

> 2.Also I need to be able to force a different path and even database
> name: The source server where I create the backup file may have a
> different location than I have on my machine, so what parameters can I
> give the command so that it will use the location I specifiy?

You use MOVE:

RESTORE DATABASE mydatase FROM disk = 'C:\temp\mydump.bak'
WITH MOVE 'mydatabase_data' TO 'e:\mylocation\mydatabase.mdf',
MOVE 'mydatabase_log' TO 'f:\myloglocation\mydatabase.ldf',
REPLACE

It does not seem that you can use variable in place of the device
and paths, but you could build the BACKUP command dynamically and
execute with EXEC(@.sql).

> 3.The database name on the source server may be ABC, but I may want to
> restore over XYZ. How can I force that? Perhaps it would be the same
> parameter I need for 2.

RESTORE DATABASE XYZ ...

There is no law that says that the database you restore to must have
the same name as the source database.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||>Question: are you restoring model, because you really need a copy of model
>from the other box on your machine? Or did you just pick model as a test
>case? In the former case, the easiest may be to script any user objects
>you have in model, and run the script. I would not really expect that
>you have any data in model. If you are just testing, try Northwind or
>pubs instead.

Yes, Model was just for testing. I will try another database.

>You use MOVE:
> RESTORE DATABASE mydatase FROM disk = 'C:\temp\mydump.bak'
> WITH MOVE 'mydatabase_data' TO 'e:\mylocation\mydatabase.mdf',
> MOVE 'mydatabase_log' TO 'f:\myloglocation\mydatabase.ldf',
> REPLACE

Excellent. I will put that to use.

>It does not seem that you can use variable in place of the device
>and paths, but you could build the BACKUP command dynamically and
>execute with EXEC(@.sql).

I will need to build the command dynamically as you say. But first I need to extract the destination path. How?

>RESTORE DATABASE XYZ ...
>There is no law that says that the database you restore to must have
>the same name as the source database.

I've been trying that to no avail. Well, maybe it will work after I get the other issues resolved, but so far, the error
messages complain about the original database name.

Thank you very, very much.

Jon|||Jon Jacobs (JonJacobsAtcomcast.net) writes:
> I will need to build the command dynamically as you say. But first I
> need to extract the destination path. How?

Well, I silently passed over that question, since I can't really tell
from a distance where you want to have your databases.

But assuming that you want the database in the default location of the
server.

This information is stored in the registry of the server, and you can
retrieve it with xp_regread. However, this is a undocumented and
unsupported function. (Note also that with SQL 2000 SP4, the function
will be restricted to access to SQL Server own values.)

A somewhat more roundabout way of doing it, is this:

CREATE DATABASE temp
SELECT @.path = filename FROM sysdatabases WHERE name = 'temp'
SELECT @.path = replace(@.path, '//', '/')
SELECT @.path = substring(@.path, 1, len(@.path) - len('temp.mdf'))
DROP DATABASE temp

>>RESTORE DATABASE XYZ ...
>>
>>There is no law that says that the database you restore to must have
>>the same name as the source database.
> I've been trying that to no avail. Well, maybe it will work after I get
> the other issues resolved, but so far, the error messages complain about
> the original database name.

You to use WITH REPLACE in this case. Since you already had this in
your example, I did not mention this.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Thursday, March 8, 2012

database restore issue

I cannot restore a differential database backup on top of a full back up for
some reason. I am installing it on a seperate server from a "device" , i
dont know what I ma doing wrong. Obviously I am new to sql server
administration. Any help will be appreciated.
best
Jay
Also, please post the exact error message...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"John" <anonymous@.discussions.microsoft.com> wrote in message news:22f7001c45e15$ba2d4670$a301280a@.phx.gbl...[vbcol=seagreen]
> Is there another backup between the full backup and
> differential backup?
>
> a full back up for
> a "device" , i
> sql server
|||No there isnt another backup between the Full and differential database
backup.
The exact error message is somehting of the effect that
"Microsoft SQL-DMO(ODBC SQL State:42000)
Cannot apply the backup on device 'D:\TestDB\x-D.bak' to database 'X'.
RESTORE DATABASE is terminating abnormally.
Its kinds frusterating because I dont know enough about the subject to be
able to troubleshoot this error convinceingly. I appreciate the help you
guys are offereing.
-Jay
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:e5yevchXEHA.648@.TK2MSFTNGP10.phx.gbl...
> Also, please post the exact error message...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "John" <anonymous@.discussions.microsoft.com> wrote in message
news:22f7001c45e15$ba2d4670$a301280a@.phx.gbl...
>

database restore issue

I cannot restore a differential database backup on top of a full back up for
some reason. I am installing it on a seperate server from a "device" , i
dont know what I ma doing wrong. Obviously I am new to sql server
administration. Any help will be appreciated.
best
Jay
Also, please post the exact error message...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"John" <anonymous@.discussions.microsoft.com> wrote in message news:22f7001c45e15$ba2d4670$a301280a@.phx.gbl...[vbcol=seagreen]
> Is there another backup between the full backup and
> differential backup?
>
> a full back up for
> a "device" , i
> sql server
|||No there isnt another backup between the Full and differential database
backup.
The exact error message is somehting of the effect that
"Microsoft SQL-DMO(ODBC SQL State:42000)
Cannot apply the backup on device 'D:\TestDB\x-D.bak' to database 'X'.
RESTORE DATABASE is terminating abnormally.
Its kinds frusterating because I dont know enough about the subject to be
able to troubleshoot this error convinceingly. I appreciate the help you
guys are offereing.
-Jay
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:e5yevchXEHA.648@.TK2MSFTNGP10.phx.gbl...
> Also, please post the exact error message...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "John" <anonymous@.discussions.microsoft.com> wrote in message
news:22f7001c45e15$ba2d4670$a301280a@.phx.gbl...
>
|||Hi,
You have to restore the full database backup with "norecovery" and then
restoring the
differential with "recovery" option. If you have not specified the
NORECOVERY option during your
FULL backup restore , the database will become open and you will not be able
to apply a subsequent backups (
Differential or transaction log) above that
RESTORE Database <dbname> from disk='fullbackup' with NORECOVERY
go
RESTORE Database <dbname> from disk='diff_backup' with RECOVERY
Thanks
Hari
MCDBA
"Jay Taylor" <help4u@.gmail.com> wrote in message
news:uZqceShXEHA.3640@.TK2MSFTNGP11.phx.gbl...
> I cannot restore a differential database backup on top of a full back up
for
> some reason. I am installing it on a seperate server from a "device" , i
> dont know what I ma doing wrong. Obviously I am new to sql server
> administration. Any help will be appreciated.
> best
> Jay
>
|||I'm sorry but I can't really be of more help. I would triple check that you indeed work against the
correct backup files (also use RESTORE HEADERONLY), and that you really really don't have a database
backup in between. Also, do a simple test case against pubs or so, and verify that the test case
work as you expect.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Jay Taylor" <help4u@.gmail.com> wrote in message news:OpEpnyjXEHA.648@.TK2MSFTNGP10.phx.gbl...
> No there isnt another backup between the Full and differential database
> backup.
> The exact error message is somehting of the effect that
> "Microsoft SQL-DMO(ODBC SQL State:42000)
> Cannot apply the backup on device 'D:\TestDB\x-D.bak' to database 'X'.
> RESTORE DATABASE is terminating abnormally.
> Its kinds frusterating because I dont know enough about the subject to be
> able to troubleshoot this error convinceingly. I appreciate the help you
> guys are offereing.
> -Jay
>
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:e5yevchXEHA.648@.TK2MSFTNGP10.phx.gbl...
> news:22f7001c45e15$ba2d4670$a301280a@.phx.gbl...
>

database restore issue

I cannot restore a differential database backup on top of a full back up for
some reason. I am installing it on a seperate server from a "device" , i
dont know what I ma doing wrong. Obviously I am new to sql server
administration. Any help will be appreciated.
best
JayHi,
You have to restore the full database backup with "norecovery" and then
restoring the
differential with "recovery" option. If you have not specified the
NORECOVERY option during your
FULL backup restore , the database will become open and you will not be able
to apply a subsequent backups (
Differential or transaction log) above that
RESTORE Database <dbname> from disk='fullbackup' with NORECOVERY
go
RESTORE Database <dbname> from disk='diff_backup' with RECOVERY
Thanks
Hari
MCDBA
"Jay Taylor" <help4u@.gmail.com> wrote in message
news:uZqceShXEHA.3640@.TK2MSFTNGP11.phx.gbl...
> I cannot restore a differential database backup on top of a full back up
for
> some reason. I am installing it on a seperate server from a "device" , i
> dont know what I ma doing wrong. Obviously I am new to sql server
> administration. Any help will be appreciated.
> best
> Jay
>

database restore issue

I cannot restore a differential database backup on top of a full back up for
some reason. I am installing it on a seperate server from a "device" , i
dont know what I ma doing wrong. Obviously I am new to sql server
administration. Any help will be appreciated.
best
JayAlso, please post the exact error message...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"John" <anonymous@.discussions.microsoft.com> wrote in message news:22f7001c45e15$ba2d4670$a301280a@.phx.gbl...
> Is there another backup between the full backup and
> differential backup'
>
> >--Original Message--
> >I cannot restore a differential database backup on top of
> a full back up for
> >some reason. I am installing it on a seperate server from
> a "device" , i
> >dont know what I ma doing wrong. Obviously I am new to
> sql server
> >administration. Any help will be appreciated.
> >
> >best
> >Jay
> >
> >
> >.
> >|||No there isnt another backup between the Full and differential database
backup.
The exact error message is somehting of the effect that
"Microsoft SQL-DMO(ODBC SQL State:42000)
Cannot apply the backup on device 'D:\TestDB\x-D.bak' to database 'X'.
RESTORE DATABASE is terminating abnormally.
Its kinds frusterating because I dont know enough about the subject to be
able to troubleshoot this error convinceingly. I appreciate the help you
guys are offereing.
-Jay
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:e5yevchXEHA.648@.TK2MSFTNGP10.phx.gbl...
> Also, please post the exact error message...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "John" <anonymous@.discussions.microsoft.com> wrote in message
news:22f7001c45e15$ba2d4670$a301280a@.phx.gbl...
> > Is there another backup between the full backup and
> > differential backup'
> >
> >
> >
> > >--Original Message--
> > >I cannot restore a differential database backup on top of
> > a full back up for
> > >some reason. I am installing it on a seperate server from
> > a "device" , i
> > >dont know what I ma doing wrong. Obviously I am new to
> > sql server
> > >administration. Any help will be appreciated.
> > >
> > >best
> > >Jay
> > >
> > >
> > >.
> > >
>|||Hi,
You have to restore the full database backup with "norecovery" and then
restoring the
differential with "recovery" option. If you have not specified the
NORECOVERY option during your
FULL backup restore , the database will become open and you will not be able
to apply a subsequent backups (
Differential or transaction log) above that
RESTORE Database <dbname> from disk='fullbackup' with NORECOVERY
go
RESTORE Database <dbname> from disk='diff_backup' with RECOVERY
Thanks
Hari
MCDBA
"Jay Taylor" <help4u@.gmail.com> wrote in message
news:uZqceShXEHA.3640@.TK2MSFTNGP11.phx.gbl...
> I cannot restore a differential database backup on top of a full back up
for
> some reason. I am installing it on a seperate server from a "device" , i
> dont know what I ma doing wrong. Obviously I am new to sql server
> administration. Any help will be appreciated.
> best
> Jay
>|||I'm sorry but I can't really be of more help. I would triple check that you indeed work against the
correct backup files (also use RESTORE HEADERONLY), and that you really really don't have a database
backup in between. Also, do a simple test case against pubs or so, and verify that the test case
work as you expect.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Jay Taylor" <help4u@.gmail.com> wrote in message news:OpEpnyjXEHA.648@.TK2MSFTNGP10.phx.gbl...
> No there isnt another backup between the Full and differential database
> backup.
> The exact error message is somehting of the effect that
> "Microsoft SQL-DMO(ODBC SQL State:42000)
> Cannot apply the backup on device 'D:\TestDB\x-D.bak' to database 'X'.
> RESTORE DATABASE is terminating abnormally.
> Its kinds frusterating because I dont know enough about the subject to be
> able to troubleshoot this error convinceingly. I appreciate the help you
> guys are offereing.
> -Jay
>
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:e5yevchXEHA.648@.TK2MSFTNGP10.phx.gbl...
> > Also, please post the exact error message...
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > http://www.karaszi.com/sqlserver/default.asp
> > http://www.solidqualitylearning.com/
> >
> >
> > "John" <anonymous@.discussions.microsoft.com> wrote in message
> news:22f7001c45e15$ba2d4670$a301280a@.phx.gbl...
> > > Is there another backup between the full backup and
> > > differential backup'
> > >
> > >
> > >
> > > >--Original Message--
> > > >I cannot restore a differential database backup on top of
> > > a full back up for
> > > >some reason. I am installing it on a seperate server from
> > > a "device" , i
> > > >dont know what I ma doing wrong. Obviously I am new to
> > > sql server
> > > >administration. Any help will be appreciated.
> > > >
> > > >best
> > > >Jay
> > > >
> > > >
> > > >.
> > > >
> >
> >
>

Friday, February 24, 2012

database recovery

Hi,
I'm no where close to a SQL Server expert but we're using it as a back end
to another application.

I lost a PC that had MS SQL Server 2000. I was able to recover the .MDF and
..LDF files but nothing else. How can I restore these files to another SQL
Server installation on another PC. When I tried to attach them they are not
recognized as valid files (I get the red X instead of the green CHECK).

Is this a basic security function that I'm not going to get around or should
it be possible? Do the .mdf and .ldf files contain specific info about what
PC they were created on?

Are there third party apps that might be able to at least extract the
tables?

Thanks,
WHHi

Try attaching them using from Query Analyser using the sp_attach_db stored
procedure (see Books online)
EXEC sp_attach_db @.dbname = N'pubs',
@.filename1 = N'c:\Program Files\Microsoft SQL
Server\MSSQL\Data\pubs.mdf',
@.filename2 = N'c:\Program Files\Microsoft SQL
Server\MSSQL\Data\pubs_log.ldf'If that fails you may have to resort to your
database backups.John"WH" <user@.server.com> wrote in message
news:IJsvd.16071$NO5.1938@.twister.rdc-kc.rr.com...
> Hi,
> I'm no where close to a SQL Server expert but we're using it as a back end
> to another application.
> I lost a PC that had MS SQL Server 2000. I was able to recover the .MDF
> and
> .LDF files but nothing else. How can I restore these files to another SQL
> Server installation on another PC. When I tried to attach them they are
> not
> recognized as valid files (I get the red X instead of the green CHECK).
> Is this a basic security function that I'm not going to get around or
> should
> it be possible? Do the .mdf and .ldf files contain specific info about
> what
> PC they were created on?
> Are there third party apps that might be able to at least extract the
> tables?
> Thanks,
> WH

Friday, February 17, 2012

Database performance degrading (again)

We have an application with a SQL Server 2000 back end that is fairly
database intensive -- lots of fairly frequent queries, inserts, updates
-- the gamut. The application does not make use of performance hogs
like cursors, but I know there are lots of ways the application could
be made more efficient database-wise. The server code is running VB6
of all things, using COM+ database interfaces. There are some
clustered and non-clustered indexes defined, but I'm pretty sure
there's room for improvement there as well.

Some tables have grown into the millions of records in recent months,
and performance of the application slowed to a crawl. Optimizing the
database helped a little, but not much. We know that several million
records in a table is a lot, but one would think that SQL Server should
be able to still handle that pretty well. We do have plans to archive
a lot of old data, but in the meantime, we were hurting for a quick
fix.

So we threw hardware at the problem, and transferred the database to a
new, more powerful server. The performance improvement was dramatic.
Transactions were many many times faster than before. Without
implementing any of the other more difficult performance improvements
we have planned, we suddenly became minor heros. :-)

Well, the honeymoon seems to be somewhat over. While performance is
still much better than when the database resided on our old server,
performance appears to have degraded rather significantly again.
Performance is also not significantly better with fewer users on our
system. What the heck?

Yes, the database continues to grow unchecked as we haven't quite got
an archive utility in place yet, but the growth is relatively gradual,
so you wouldn't think that would be the issue. The database is
optimized on a weekly basis, and our web and database servers are both
rebooted monthly. Our database administrators don't seem to have
answers, so I appeal to the experts reading this forum to maybe offer
some clues.

Prior to posting I did do a fair amount of research to see what people
have suggested in similar situations, and ran this by our database
admin. Here's what I can tell you from this research:

- Statistics are updated weekly along with whatever else the database
optimization does

- We do not use the "autoshrink" option for automatically shrinking log
files

- Regarding preallocating space and setting growth factors for log and
data files to minimize time spent allocating disk space, our admin
says, "We do allow database files to grow unchecked, but we do monitor
growth and manually expand as needed. Autogrow is typically set in
50MB increments or less as the amount of time it takes to expand this
amount is negligible."

- Transaction logging is turned on, and data and log devices are on
separate physical disks

- The database server is monitored to ensure no process is hogging all
of the CPU, I/O or memory> We know that several million records in a table is a lot
Not really. It all depends on your hardware and how your application
has been written. I've used tables that are in the tens of millions of
records (even close to 100 million) without encountering performance
problems.

Have you run Profiler to see where the slowness is originating? A good
idea would be to run profiler, logging to a table, for a day. Use that
data to find the longest running SQL statements as well as the most
commonly used SQL statements. Concentrate your efforts on improving
those queries that appear in both categories - i.e. SQL statements that
take a long time to run and which are frequently used. If you check out
Microsoft's website I'm sure that you can find a whitepaper on using
Profiler to optimize a database application.

Another thing to look at is how the front end application is accessing
the server. Is it making a lot of unnecessary round trips to the SQL
Server? Network latency can also play into this a lot. If your frontend
application is scrolling through records in your table one at a time,
retrieving each one individually, it doesn't matter how fast your
database is, the application will be slow.

This is one problem with throwing hardware at a database issue. The
problem that is causing the slowness will almost always come up again
until you fix the part of the database/application that is causing the
issue in the first place.

Hopefully these ideas will yield some improvements for you.

Good luck,
-Tom.|||(teedilo@.hotmail.com) writes:
> Some tables have grown into the millions of records in recent months,
> and performance of the application slowed to a crawl. Optimizing the
> database helped a little, but not much. We know that several million
> records in a table is a lot, but one would think that SQL Server should
> be able to still handle that pretty well.

Well, let me put it this way: a couple of million row tables is
enough to make SQL Server slower than a snail if you have poor indexing
or malformed queries. But as Thomas said: you can have over 100 million
rows, and excellent performance. All depends on the matching between
queries and indexes.

> So we threw hardware at the problem, and transferred the database to a
> new, more powerful server. The performance improvement was dramatic.
> Transactions were many many times faster than before.

Since SQL Server uses a cost-based optimizer, the same query with the
same indexes can give different qurey plans, with a little difference
in statistics. If there was such a drastic changes, it seems that the
tables were turned in favour of better plans.

> Well, the honeymoon seems to be somewhat over. While performance is
> still much better than when the database resided on our old server,
> performance appears to have degraded rather significantly again.
> Performance is also not significantly better with fewer users on our
> system. What the heck?

And you ask us who don't even see the system!

As Thomas said, use the Profiler to track down slow-running queries,
and address them one by one; either by rewriting or modifying indexes.
Or take a shortcut: save a day's workload, and feed it to the Index
Tunig Wizard.

> - Statistics are updated weekly along with whatever else the database
> optimization does

Nevertheless, if can be good idea to do DBCC SHOWCONTIG on some
big table, to check for fragmentation.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Thanks for your replies, Tom and Erland.

Yes, I know that several million records in a table is not necessarily
a lot, especially if the application, database, indexes, etc. are all
well designed. I'll concede that that's probably not the case here!

And yes, I'm sure that network latency contributes to our problems, as
there are a fair amount of round trips going on that probably wouldn't
be necessary if the application were better designed. The consistency
of the bad performance seems to suggest that the degradation in
performance has more to do with the database, however.

I like the Profiler suggestion, which we've been talking about doing
anyway. It's too bad that we didn't do that right after moving to this
new server so we could maybe pinpoint what has changed to make it run
slower.

I also like the suggestion of running DBCC SHOWCONTIG on the bigger
tables to see if there's significant fragmentation even though we've
been optimizing every week.

I also appreciate Erland's comment that it's difficult for someone on
the outside to know what's really going on. I just figured that there
*might* be fairly common/general things to look for/do in the situation
where 1) performance was awful on an old server, 2) performance was
vastly improved when the database was moved to a new server, and 3)
performance quickly degraded again on the new server.

Yes, I know that throwing hardware at the problem is not a silver
bullet. Our old server needed replacing anyway, so we figured it was
worth doing, at least as a stopgap measure to improve performance,
while we were still working on the more difficult fixes. And while I
am not surprised that some slowness would arise again as Tom suggests,
I am rather surprised that the degradation was as significant as it was
in a relatively few short months since the new server was put into
place. In fact, my theory is that reformatting the new server and
starting completely from scratch would suddenly give us improved
performance again -- just a hunch.

One thing that confuses me a little in relation to Erland's comments
about SQL Server's cost-based optimizer. I've read a little about
this, how SQL Server continually tries to find better execution plans,
etc. But wouldn't that lead to *improved* performance instead of worse
performance? Or is it possible that SQL Server will occasionally make
the "wrong choice" in terms of finding execution plans that offer
better performance?

Thanks much again for your suggestions. They're probably about as good
as I can expect given the lack of specific information that I can offer
on this problem.|||> One thing that confuses me a little in relation to Erland's comments
> about SQL Server's cost-based optimizer. I've read a little about
> this, how SQL Server continually tries to find better execution plans,
> etc. But wouldn't that lead to *improved* performance instead of worse
> performance?

Indexes are the key to an efficient execution plan. Statistics on
non-indexed columns can help too (but to a lesser extent) and SQL Server can
generate column statistics automatically. However, indexes are entirely up
to you because you need to balance the cost of maintaining indexes with data
retrieval performance benefits. This is where Profiler and execution plan
analysis can help you out.

When you start with a well-designed database and application, the SQL Server
cost-based optimizer usually does a pretty good job of adapting to changes
in data volume and cardinality. When you don't have appropriate indexes,
the optimizer can't do much to help you out and performance degrades with
data volume. This appears to be the case in your environment based on your
description of the problem.

> Or is it possible that SQL Server will occasionally make
> the "wrong choice" in terms of finding execution plans that offer
> better performance?

Yes, it possible that the optimizer makes the wrong choice. When you find
an execution plan that isn't using indexes effectively, first ensure stats
are up-to-date and expressions are sargable. You can specify hints to
override the cost-based optimizer choices but this should be done as a only
as a last resort.

--
Hope this helps.

Dan Guzman
SQL Server MVP

<teedilo@.hotmail.com> wrote in message
news:1109981213.142149.22520@.o13g2000cwo.googlegro ups.com...
> Thanks for your replies, Tom and Erland.
> Yes, I know that several million records in a table is not necessarily
> a lot, especially if the application, database, indexes, etc. are all
> well designed. I'll concede that that's probably not the case here!
> And yes, I'm sure that network latency contributes to our problems, as
> there are a fair amount of round trips going on that probably wouldn't
> be necessary if the application were better designed. The consistency
> of the bad performance seems to suggest that the degradation in
> performance has more to do with the database, however.
> I like the Profiler suggestion, which we've been talking about doing
> anyway. It's too bad that we didn't do that right after moving to this
> new server so we could maybe pinpoint what has changed to make it run
> slower.
> I also like the suggestion of running DBCC SHOWCONTIG on the bigger
> tables to see if there's significant fragmentation even though we've
> been optimizing every week.
> I also appreciate Erland's comment that it's difficult for someone on
> the outside to know what's really going on. I just figured that there
> *might* be fairly common/general things to look for/do in the situation
> where 1) performance was awful on an old server, 2) performance was
> vastly improved when the database was moved to a new server, and 3)
> performance quickly degraded again on the new server.
> Yes, I know that throwing hardware at the problem is not a silver
> bullet. Our old server needed replacing anyway, so we figured it was
> worth doing, at least as a stopgap measure to improve performance,
> while we were still working on the more difficult fixes. And while I
> am not surprised that some slowness would arise again as Tom suggests,
> I am rather surprised that the degradation was as significant as it was
> in a relatively few short months since the new server was put into
> place. In fact, my theory is that reformatting the new server and
> starting completely from scratch would suddenly give us improved
> performance again -- just a hunch.
> One thing that confuses me a little in relation to Erland's comments
> about SQL Server's cost-based optimizer. I've read a little about
> this, how SQL Server continually tries to find better execution plans,
> etc. But wouldn't that lead to *improved* performance instead of worse
> performance? Or is it possible that SQL Server will occasionally make
> the "wrong choice" in terms of finding execution plans that offer
> better performance?
> Thanks much again for your suggestions. They're probably about as good
> as I can expect given the lack of specific information that I can offer
> on this problem.|||(teedilo@.hotmail.com) writes:
> I also appreciate Erland's comment that it's difficult for someone on
> the outside to know what's really going on. I just figured that there
> *might* be fairly common/general things to look for/do in the situation
> where 1) performance was awful on an old server, 2) performance was
> vastly improved when the database was moved to a new server, and 3)
> performance quickly degraded again on the new server.

So how did you migrate the database? If you now say "Copy Database
Wizard" or any other methods that include rebuild of the database,
I'm tempted to place my bets on fragmentation as the main issue. To
wit, if you move the database in this way, you get quite a well-
defragmented database in the other end.

If you migrated the database my means of backup/restore or detach/attach,
your also copied the fragmentation. In this case... I could go into
speculation, but it would not really address the actual problem.

> One thing that confuses me a little in relation to Erland's comments
> about SQL Server's cost-based optimizer. I've read a little about
> this, how SQL Server continually tries to find better execution plans,
> etc. But wouldn't that lead to *improved* performance instead of worse
> performance? Or is it possible that SQL Server will occasionally make
> the "wrong choice" in terms of finding execution plans that offer
> better performance?

To say that SQL Server constantly try to find better query plans, is
not maybe really correct. (That's more applicable to the SQL Server
dev team.) But SQL Server do occasionally review query plans, because
statistics have changed - or because the query plan has fallen out of
cache.

And plans are bulit on estimates from statistics, and they are indeed
a gamble. Sometimes the opimtizer makes very bad picks for one reason
or another. This also applies to different SQL Server versions. MS
does some tweak to the optimizer, which in many cases are beneficiary,
but at some sites can backfire.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Hi

Glancing through the posts it is not clear what maintenace you are doing
other than the weekly updating the statistics, so I will add my two pence
worth!!!

Your DBCC SHOWCONTIG will probably indicate fragmentation if you don't have
maintenace in place that calls DBCC INDEXDEFRAG and/or DBCC DBREINDEX. You
may also want to look at running the index tuning wizard on your profiles to
see if it suggests alternate fill factors. You may want to try alternate
fill factors on a different (controlled) system and replay the profiles
against it to see what fragmentation and speed you can achieve.

John

<teedilo@.hotmail.com> wrote in message
news:1109981213.142149.22520@.o13g2000cwo.googlegro ups.com...
> Thanks for your replies, Tom and Erland.
> Yes, I know that several million records in a table is not necessarily
> a lot, especially if the application, database, indexes, etc. are all
> well designed. I'll concede that that's probably not the case here!
> And yes, I'm sure that network latency contributes to our problems, as
> there are a fair amount of round trips going on that probably wouldn't
> be necessary if the application were better designed. The consistency
> of the bad performance seems to suggest that the degradation in
> performance has more to do with the database, however.
> I like the Profiler suggestion, which we've been talking about doing
> anyway. It's too bad that we didn't do that right after moving to this
> new server so we could maybe pinpoint what has changed to make it run
> slower.
> I also like the suggestion of running DBCC SHOWCONTIG on the bigger
> tables to see if there's significant fragmentation even though we've
> been optimizing every week.
> I also appreciate Erland's comment that it's difficult for someone on
> the outside to know what's really going on. I just figured that there
> *might* be fairly common/general things to look for/do in the situation
> where 1) performance was awful on an old server, 2) performance was
> vastly improved when the database was moved to a new server, and 3)
> performance quickly degraded again on the new server.
> Yes, I know that throwing hardware at the problem is not a silver
> bullet. Our old server needed replacing anyway, so we figured it was
> worth doing, at least as a stopgap measure to improve performance,
> while we were still working on the more difficult fixes. And while I
> am not surprised that some slowness would arise again as Tom suggests,
> I am rather surprised that the degradation was as significant as it was
> in a relatively few short months since the new server was put into
> place. In fact, my theory is that reformatting the new server and
> starting completely from scratch would suddenly give us improved
> performance again -- just a hunch.
> One thing that confuses me a little in relation to Erland's comments
> about SQL Server's cost-based optimizer. I've read a little about
> this, how SQL Server continually tries to find better execution plans,
> etc. But wouldn't that lead to *improved* performance instead of worse
> performance? Or is it possible that SQL Server will occasionally make
> the "wrong choice" in terms of finding execution plans that offer
> better performance?
> Thanks much again for your suggestions. They're probably about as good
> as I can expect given the lack of specific information that I can offer
> on this problem.