Greetings. I've been having a problem with one of our customer's database and its driving me insane. Its a pretty lengthy problem so please bare with me.
A few years ago I wrote an application that stores client-visit information into an SQL Server 2000 database. Here is a copy of the design of the table, which is called "tblVisits":
*NOTE* I'm sure a few people are going to mention that because of the lengths of the Notes1 and Notes2 fields, that a problem might occur. Please keep in mind that this application has been in production for a 3+ years and has never been a problem.
Recently, we wrote an upgrade to this application and gave it to this customer to test. We've made some additional changes to the "tblVisits" table. Here is what the current table looks like now:
Now, when the application attempts to write to this table, the INSERT statement slows down dramatically. Before the INSERT statement would take less than a second to run. Now, it takes 45+ seconds and sometimes times out.
Does anyone know why this might have happened? Could this problem be because of the changes we made to this table? The application does not slow down on any of the other tables, just this one.
Here's some additional information on this problem:
1) SQL Server Information:
- SQL Server 2000
- All service packs have been applied.
- Our database is the only database on this server.
2) Index:
The table is only indexed by its primary key, the VisitID field.
3) Table Row Size:
I have a user-defined function that returns the number of bytes left to use if I wanted to create more rows. When I run this function against this table, I get -30.
4) Largest Row Length:
I also wrote a query that uses the DATALENGTH() function to get the total size of data for each record. The record with the largest row length was 8,013.
5) Bulk Copy Program:
Since I was not able to duplicate this problem on my development machine, I asked my customer if he could get me a copy of the table so that I can then import it into my development machine for testing. We used the Bulk Copy Program (BCP) utility to export his data to a .bcp file and then he sent it to me. I then used the BCP utility to import his data to my test database. After I did this, I was still not able to duplicate his problem.
(txmed)
A few years ago I wrote an application that stores client-visit information into an SQL Server 2000 database. Here is a copy of the design of the table, which is called "tblVisits":
Code:
[COLOR=red]Column Name Data Type Length[/color]
VisitID numeric 9 (PKey)
PrimaryVisitID numeric 9
ClientID varchar 20
VisitDate datetime 8
VisitTimeIn datetime 8
VisitTimeOut datetime 8
UserName varchar 20
DepartmentID int 4
Notes1 nvarchar 4000
Notes2 nvarchar 4000
BusinessID int 4
AssignedToUser bit 1
*NOTE* I'm sure a few people are going to mention that because of the lengths of the Notes1 and Notes2 fields, that a problem might occur. Please keep in mind that this application has been in production for a 3+ years and has never been a problem.
Recently, we wrote an upgrade to this application and gave it to this customer to test. We've made some additional changes to the "tblVisits" table. Here is what the current table looks like now:
Code:
[COLOR=red]Column Name Data Type Length[/color]
VisitID numeric 9 (PKey)
PrimaryVisitID numeric 9
ClientID varchar 20
VisitDate datetime 8
VisitTimeIn datetime 8
VisitTimeOut datetime 8
UserName varchar 20
DepartmentID int 4
Notes1 nvarchar 4000
Notes2 nvarchar 4000
BusinessID int 4
AssignedToUser bit 1
[COLOR=blue]
RoleID int 4
EncryptionType smallint 2
IsNewVisit bit 1
IsDeleted bit 1
[/color]
Now, when the application attempts to write to this table, the INSERT statement slows down dramatically. Before the INSERT statement would take less than a second to run. Now, it takes 45+ seconds and sometimes times out.
Does anyone know why this might have happened? Could this problem be because of the changes we made to this table? The application does not slow down on any of the other tables, just this one.
Here's some additional information on this problem:
1) SQL Server Information:
- SQL Server 2000
- All service packs have been applied.
- Our database is the only database on this server.
2) Index:
The table is only indexed by its primary key, the VisitID field.
3) Table Row Size:
I have a user-defined function that returns the number of bytes left to use if I wanted to create more rows. When I run this function against this table, I get -30.
4) Largest Row Length:
I also wrote a query that uses the DATALENGTH() function to get the total size of data for each record. The record with the largest row length was 8,013.
5) Bulk Copy Program:
Since I was not able to duplicate this problem on my development machine, I asked my customer if he could get me a copy of the table so that I can then import it into my development machine for testing. We used the Bulk Copy Program (BCP) utility to export his data to a .bcp file and then he sent it to me. I then used the BCP utility to import his data to my test database. After I did this, I was still not able to duplicate his problem.
(txmed)