Monday, March 12, 2012
Re-indexing required?
else, it keeps a log file of all the actions a user has taken during his use
of the app.
This log file is stored in a database table that has a primary key of type
"bigint" that auto increments (1, 1).
If ~100 to ~500 actions (insertions, deletions) are made to this table per
day, how long before I need to re-index the table? Do I need to re-index it
at all?
Thanks in advance,
Peter
pnp,
When are your maintenance windows? Do you have ANY maintenance windows? If you get a chance it would be good to recreate your indexes using the CREATE INDEX statement and the DROP_EXISTING clause - however test this for performance against DBCC DBREINDEX.
Remember that these are OFFLINE operations and will lock tables.
If you don't have a maintenance window, then measure your defragmentation using DBCC SHOWCONTIG. Based on a value acceptable to you, you can rebuild your index with DBCC INDEXDEFRAG - this is an ONLINE operation and will not lock tables, however it is not
as thorough as the other methods.
My advice would be to run DBCC SHOWCONTIG first before doing a rebuild, and then decide when to do it based on your maintenance windows. From the activity you describe it sounds like you may need to monitor it daily with DBCC SHOWCONTIG.
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
|||Hi,
Execute the below command with in the database to identify the
fragmentation,
DBCC SHOWCONTIG ('table_name') WITH FAST
DBCC SHOWCONTIG determines whether the table is heavily fragmented. Table
fragmentation occurs through the process of data modifications (INSERT,
UPDATE, and DELETE statements) made against the table. This
will cause additional page reads results in slow performance.
How to over come the Fragmentation:
1. Drop and re-create a clustered index.
2. DBCC INDEXDEFRAG (Refer books online)
Have a look into DBCC SHOWCONTIG in books online for more information.
Thanks
Hari
MCDBA
"pnp" <pnp.at.softlab.ece.ntua.gr> wrote in message
news:eoKusYJGEHA.3880@.TK2MSFTNGP10.phx.gbl...
> Hi, I'm developing a database driven application that, besides everything
> else, it keeps a log file of all the actions a user has taken during his
use
> of the app.
> This log file is stored in a database table that has a primary key of type
> "bigint" that auto increments (1, 1).
> If ~100 to ~500 actions (insertions, deletions) are made to this table per
> day, how long before I need to re-index the table? Do I need to re-index
it
> at all?
> Thanks in advance,
> Peter
>
|||On a slighly different thread.
I'd be curious to know how SQL Server indexes deal with incremental keys.
Other RDBMS implemented hash indexes as btrees can become lopsided with
these keys.
Paul Cahill
"Hari" <hari_prasad_k@.hotmail.com> wrote in message
news:eoOuuoJGEHA.1180@.TK2MSFTNGP09.phx.gbl...
> Hi,
> Execute the below command with in the database to identify the
> fragmentation,
> DBCC SHOWCONTIG ('table_name') WITH FAST
> DBCC SHOWCONTIG determines whether the table is heavily fragmented. Table
> fragmentation occurs through the process of data modifications (INSERT,
> UPDATE, and DELETE statements) made against the table. This
> will cause additional page reads results in slow performance.
> How to over come the Fragmentation:
> 1. Drop and re-create a clustered index.
> 2. DBCC INDEXDEFRAG (Refer books online)
> Have a look into DBCC SHOWCONTIG in books online for more information.
> Thanks
> Hari
> MCDBA
>
> "pnp" <pnp.at.softlab.ece.ntua.gr> wrote in message
> news:eoKusYJGEHA.3880@.TK2MSFTNGP10.phx.gbl...
everything
> use
type
per
> it
>
|||To add to all the other (sound) advice, please checkout the excellent
whitepaper at
http://www.microsoft.com/technet/pro.../ss2kidbp.mspx
It gives extensive details on how to diagnose and cope with fragmentation,
including working out which indexes to focus on and even whether you need to
bother, based on your workload.
Regards.
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"pnp" <pnp.at.softlab.ece.ntua.gr> wrote in message
news:eoKusYJGEHA.3880@.TK2MSFTNGP10.phx.gbl...
> Hi, I'm developing a database driven application that, besides everything
> else, it keeps a log file of all the actions a user has taken during his
use
> of the app.
> This log file is stored in a database table that has a primary key of type
> "bigint" that auto increments (1, 1).
> If ~100 to ~500 actions (insertions, deletions) are made to this table per
> day, how long before I need to re-index the table? Do I need to re-index
it
> at all?
> Thanks in advance,
> Peter
>
Re-indexing required?
else, it keeps a log file of all the actions a user has taken during his use
of the app.
This log file is stored in a database table that has a primary key of type
"bigint" that auto increments (1, 1).
If ~100 to ~500 actions (insertions, deletions) are made to this table per
day, how long before I need to re-index the table? Do I need to re-index it
at all?
Thanks in advance,
Peterpnp,
When are your maintenance windows? Do you have ANY maintenance windows? If y
ou get a chance it would be good to recreate your indexes using the CREATE I
NDEX statement and the DROP_EXISTING clause - however test this for performa
nce against DBCC DBREINDEX.
Remember that these are OFFLINE operations and will lock tables.
If you don't have a maintenance window, then measure your defragmentation us
ing DBCC SHOWCONTIG. Based on a value acceptable to you, you can rebuild you
r index with DBCC INDEXDEFRAG - this is an ONLINE operation and will not loc
k tables, however it is not
as thorough as the other methods.
My advice would be to run DBCC SHOWCONTIG first before doing a rebuild, and
then decide when to do it based on your maintenance windows. From the activi
ty you describe it sounds like you may need to monitor it daily with DBCC SH
OWCONTIG.
Mark Allison, SQL Server MVP
http://www.markallison.co.uk|||Hi,
Execute the below command with in the database to identify the
fragmentation,
DBCC SHOWCONTIG ('table_name') WITH FAST
DBCC SHOWCONTIG determines whether the table is heavily fragmented. Table
fragmentation occurs through the process of data modifications (INSERT,
UPDATE, and DELETE statements) made against the table. This
will cause additional page reads results in slow performance.
How to over come the Fragmentation:
1. Drop and re-create a clustered index.
2. DBCC INDEXDEFRAG (Refer books online)
Have a look into DBCC SHOWCONTIG in books online for more information.
Thanks
Hari
MCDBA
"pnp" <pnp.at.softlab.ece.ntua.gr> wrote in message
news:eoKusYJGEHA.3880@.TK2MSFTNGP10.phx.gbl...
> Hi, I'm developing a database driven application that, besides everything
> else, it keeps a log file of all the actions a user has taken during his
use
> of the app.
> This log file is stored in a database table that has a primary key of type
> "bigint" that auto increments (1, 1).
> If ~100 to ~500 actions (insertions, deletions) are made to this table per
> day, how long before I need to re-index the table? Do I need to re-index
it
> at all?
> Thanks in advance,
> Peter
>|||On a slighly different thread.
I'd be curious to know how SQL Server indexes deal with incremental keys.
Other RDBMS implemented hash indexes as btrees can become lopsided with
these keys.
Paul Cahill
"Hari" <hari_prasad_k@.hotmail.com> wrote in message
news:eoOuuoJGEHA.1180@.TK2MSFTNGP09.phx.gbl...
> Hi,
> Execute the below command with in the database to identify the
> fragmentation,
> DBCC SHOWCONTIG ('table_name') WITH FAST
> DBCC SHOWCONTIG determines whether the table is heavily fragmented. Table
> fragmentation occurs through the process of data modifications (INSERT,
> UPDATE, and DELETE statements) made against the table. This
> will cause additional page reads results in slow performance.
> How to over come the Fragmentation:
> 1. Drop and re-create a clustered index.
> 2. DBCC INDEXDEFRAG (Refer books online)
> Have a look into DBCC SHOWCONTIG in books online for more information.
> Thanks
> Hari
> MCDBA
>
> "pnp" <pnp.at.softlab.ece.ntua.gr> wrote in message
> news:eoKusYJGEHA.3880@.TK2MSFTNGP10.phx.gbl...
everything
> use
type
per
> it
>|||To add to all the other (sound) advice, please checkout the excellent
whitepaper at
http://www.microsoft.com/technet/pr...n/ss2kidbp.mspx
It gives extensive details on how to diagnose and cope with fragmentation,
including working out which indexes to focus on and even whether you need to
bother, based on your workload.
Regards.
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"pnp" <pnp.at.softlab.ece.ntua.gr> wrote in message
news:eoKusYJGEHA.3880@.TK2MSFTNGP10.phx.gbl...
> Hi, I'm developing a database driven application that, besides everything
> else, it keeps a log file of all the actions a user has taken during his
use
> of the app.
> This log file is stored in a database table that has a primary key of type
> "bigint" that auto increments (1, 1).
> If ~100 to ~500 actions (insertions, deletions) are made to this table per
> day, how long before I need to re-index the table? Do I need to re-index
it
> at all?
> Thanks in advance,
> Peter
>
Wednesday, March 7, 2012
Registration form problem. String or binary data would be truncated
Exception Details: System.Data.SqlClient.SqlException: String or binary data would be truncated. The statement has been terminated.
Stack Trace:
[SqlException: String or binary data would be truncated.
The statement has been terminated.]
Even if I leave a validated field blank, I receive the same message instead of the required field validation control error message.
Here is the code for the registration page. I use web matrix to create the code as directed in the tutorial.
Can anyone help a newbie?
Do u have all the fields in the table defined as "not null"?|||no. some fields allow nulls.Function AddMember( _
ByVal firstName As String, _
ByVal lastName As String, _
ByVal streetAddress1 As String, _
ByVal streetAddress2 As String, _
ByVal memCity As String, _
ByVal state As String, _
ByVal zipCode As String, _
ByVal primAreaCode As String, _
ByVal primPhone As String, _
ByVal primExt As String, _
ByVal secAreaCode As String, _
ByVal secPhone As String, _
ByVal secExt As String, _
ByVal memEmail As String, _
ByVal memUserID As String, _
ByVal memPassword As String, _
ByVal secretQuestion As String, _
ByVal secretAnswer As String, _
ByVal memBirthMonth As String, _
ByVal memBirthDay As String, _
ByVal memBirthYear As String) As Integer
Dim connectionString As String = "server='(local)'; trusted_connection=true; database='Members'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)Dim queryString As String = "INSERT INTO [Members] ([FirstName], [LastName], [StreetAddress1], [StreetAddress2"& _
"], [MemCity], [State], [ZipCode], [PrimAreaCode], [PrimPhone], [PrimExt], [SecAr"& _
"eaCode], [SecPhone], [SecExt], [MemEmail], [MemUserID], [MemPassword], [SecretQu"& _
"estion], [SecretAnswer], [MemBirthMonth], [MemBirthDay], [MemBirthYear]) VALUES "& _
"(@.FirstName, @.LastName, @.StreetAddress1, @.StreetAddress2, @.MemCity, @.State, @.Zip"& _
"Code, @.PrimAreaCode, @.PrimPhone, @.PrimExt, @.SecAreaCode, @.SecPhone, @.SecExt, @.Me"& _
"mEmail, @.MemUserID, @.MemPassword, @.SecretQuestion, @.SecretAnswer, @.MemBirthMonth"& _
", @.MemBirthDay, @.MemBirthYear)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnectionDim dbParam_firstName As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_firstName.ParameterName = "@.FirstName"
dbParam_firstName.Value = firstName
dbParam_firstName.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_firstName)
Dim dbParam_lastName As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_lastName.ParameterName = "@.LastName"
dbParam_lastName.Value = lastName
dbParam_lastName.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_lastName)
Dim dbParam_streetAddress1 As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_streetAddress1.ParameterName = "@.StreetAddress1"
dbParam_streetAddress1.Value = streetAddress1
dbParam_streetAddress1.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_streetAddress1)
Dim dbParam_streetAddress2 As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_streetAddress2.ParameterName = "@.StreetAddress2"
dbParam_streetAddress2.Value = streetAddress2
dbParam_streetAddress2.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_streetAddress2)
Dim dbParam_memCity As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_memCity.ParameterName = "@.MemCity"
dbParam_memCity.Value = memCity
dbParam_memCity.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_memCity)
Dim dbParam_state As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_state.ParameterName = "@.State"
dbParam_state.Value = state
dbParam_state.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_state)
Dim dbParam_zipCode As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_zipCode.ParameterName = "@.ZipCode"
dbParam_zipCode.Value = zipCode
dbParam_zipCode.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_zipCode)
Dim dbParam_primAreaCode As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_primAreaCode.ParameterName = "@.PrimAreaCode"
dbParam_primAreaCode.Value = primAreaCode
dbParam_primAreaCode.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_primAreaCode)
Dim dbParam_primPhone As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_primPhone.ParameterName = "@.PrimPhone"
dbParam_primPhone.Value = primPhone
dbParam_primPhone.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_primPhone)
Dim dbParam_primExt As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_primExt.ParameterName = "@.PrimExt"
dbParam_primExt.Value = primExt
dbParam_primExt.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_primExt)
Dim dbParam_secAreaCode As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_secAreaCode.ParameterName = "@.SecAreaCode"
dbParam_secAreaCode.Value = secAreaCode
dbParam_secAreaCode.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_secAreaCode)
Dim dbParam_secPhone As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_secPhone.ParameterName = "@.SecPhone"
dbParam_secPhone.Value = secPhone
dbParam_secPhone.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_secPhone)
Dim dbParam_secExt As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_secExt.ParameterName = "@.SecExt"
dbParam_secExt.Value = secExt
dbParam_secExt.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_secExt)
Dim dbParam_memEmail As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_memEmail.ParameterName = "@.MemEmail"
dbParam_memEmail.Value = memEmail
dbParam_memEmail.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_memEmail)
Dim dbParam_memUserID As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_memUserID.ParameterName = "@.MemUserID"
dbParam_memUserID.Value = memUserID
dbParam_memUserID.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_memUserID)
Dim dbParam_memPassword As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_memPassword.ParameterName = "@.MemPassword"
dbParam_memPassword.Value = memPassword
dbParam_memPassword.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_memPassword)
Dim dbParam_secretQuestion As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_secretQuestion.ParameterName = "@.SecretQuestion"
dbParam_secretQuestion.Value = secretQuestion
dbParam_secretQuestion.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_secretQuestion)
Dim dbParam_secretAnswer As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_secretAnswer.ParameterName = "@.SecretAnswer"
dbParam_secretAnswer.Value = secretAnswer
dbParam_secretAnswer.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_secretAnswer)
Dim dbParam_memBirthMonth As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_memBirthMonth.ParameterName = "@.MemBirthMonth"
dbParam_memBirthMonth.Value = memBirthMonth
dbParam_memBirthMonth.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_memBirthMonth)
Dim dbParam_memBirthDay As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_memBirthDay.ParameterName = "@.MemBirthDay"
dbParam_memBirthDay.Value = memBirthDay
dbParam_memBirthDay.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_memBirthDay)
Dim dbParam_memBirthYear As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_memBirthYear.ParameterName = "@.MemBirthYear"
dbParam_memBirthYear.Value = memBirthYear
dbParam_memBirthYear.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_memBirthYear)Dim rowsAffected As Integer = 0
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Finally
dbConnection.Close
End TryReturn rowsAffected
End Function
Saturday, February 25, 2012
registration and Replicatons
I am configuring replications over the internet using a VPN connection
and do not want the Publisher/Distributor (Publisher and Distributor
are the same) to have the Subscriber registered. I know you can add a
subscriber using the system stored procedure but I was wondering if
registration of the subscriber was a requirement to perform
replication.
Thank you in advance for your help.
It is required.
You must register the servers in your hosts file, client configuration utility, and EM. Then you must enable your subscriber using SQL Server authentication.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
"Gent" wrote:
> Is registration of the subscriber required to configure replications.
> I am configuring replications over the internet using a VPN connection
> and do not want the Publisher/Distributor (Publisher and Distributor
> are the same) to have the Subscriber registered. I know you can add a
> subscriber using the system stored procedure but I was wondering if
> registration of the subscriber was a requirement to perform
> replication.
> Thank you in advance for your help.
>