Showing posts with label update. Show all posts
Showing posts with label update. Show all posts

Wednesday, March 28, 2012

How often shoud we run reorganize index and update statistics...

We have a 20 GB database and reorganize indexes and update statistics maintainance takes about 4 hours and the log files grows out of control what is a serious problem since it can not be truncated (database mirroring).

Ivan

First of all if your log file is growing it just means that it is not properly sized for your environment. In fact, have a proper sized log file will cut down the reorganize time.

If you have not changed anything to the autostats setting your statistics will be updated after enough records have changed for SQL Server to consider it usefull to update them.


Are you talking about a reorganize or a rebuild of your indexes? You should rebuild your indexes once in a while and the frequency entirely depends on the fillfactor and the amount of data that is changed between your rebuilds.

Depending on how much time it takes I would say reindex as frequently as you can afford to (daily/weekly?).

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

|||

I think we have an equivalent question : How often do we use indexes or querying database ?

What are the most importants queries used by users ? You can answer at this question.

If you can do a top of this queries you can reorganize/rebuild the indexes used by first queries of the top. Later or rarely another indexes.

From other part don't farget "avg_fragmentation_in_percent value " that implies if you do reorganize or rebuild of indexes (see Books Online).

You can do this thing using a job (or Database Maintenance Plan) nightly when the people sleep.

sql

How not to replicate update statement

Hi,
In a merge replicaton, how can I configure it so that the update statements
will not be replicated to subscriber database?
Thanks.
Pingx
This can't be done. On the subscriber side you can have permissions checked
for DML originating on the subscriber and then selectively modify
permissions of the PAL account so it can't perform this DML.
http://www.zetainteractive.com - Shift Happens!
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Pingx" <Pingx@.discussions.microsoft.com> wrote in message
news:9DD5A341-4608-4EC2-A30C-6F4896F5E8A4@.microsoft.com...
> Hi,
> In a merge replicaton, how can I configure it so that the update
> statements
> will not be replicated to subscriber database?
> Thanks.
> Pingx

Friday, March 23, 2012

How many subscribers can Transactional replcation with queue update support ?

How many subscribers can Transactional replcation with queue update support
?
It is not really scalable with more than 10. Having said this I have seen it
deployed with 60 subscribers. It was not pretty. Stick with 10 or less.
Hilary Cotter
Looking for a SQL Server replication book?
Now available for purchase at:
http://www.nwsu.com/0974973602.html
"Dennis JoJo" <denniswong@.shunhinggroup.com> wrote in message
news:uPEaYkD1EHA.824@.TK2MSFTNGP11.phx.gbl...
> How many subscribers can Transactional replcation with queue update
support
> ?
>

Wednesday, March 7, 2012

How is sysindexes.rows updated by SQL Server?

I know that the rows column on sysindexes is not always accurate, and
that I can force and update by using DBCC UPDATEUSAGE, but I'm
wondering what happens "behind the scenes" so that this value is
eventually updated with the correct value.
The particular example that I'm working with is this: a developer
noticed that the rows property on the table pop-up in EM doesn't match
the actual row count. I explained to him why the values didn't match,
but I have to believe that eventually this value will be changed and
EM will report the accurate row count. Is this correct?
Thanks in advance!
Maria
One thing that corrects the value is DBCC CHECKDB (which I assume that you run regularly).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Maria Vogel" <vogelm@.meijer.com> wrote in message news:1715eae1.0405110654.460c627@.posting.google.co m...
> I know that the rows column on sysindexes is not always accurate, and
> that I can force and update by using DBCC UPDATEUSAGE, but I'm
> wondering what happens "behind the scenes" so that this value is
> eventually updated with the correct value.
> The particular example that I'm working with is this: a developer
> noticed that the rows property on the table pop-up in EM doesn't match
> the actual row count. I explained to him why the values didn't match,
> but I have to believe that eventually this value will be changed and
> EM will report the accurate row count. Is this correct?
> Thanks in advance!
> Maria
|||Tibor, no it doesn't. Only DBCC UPDATEUSAGE does it.
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:evWisr$NEHA.3596@.tk2msftngp13.phx.gbl...
> One thing that corrects the value is DBCC CHECKDB (which I assume that you
run regularly).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
>
> "Maria Vogel" <vogelm@.meijer.com> wrote in message
news:1715eae1.0405110654.460c627@.posting.google.co m...
>
|||Ahh, thanks Paul. I didn't know that was changed since the old days (I still recall 6.5, where only way to
adjust space allocation for syslogs was through CHECKDB...). :-)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
news:%23OrDTGFOEHA.1104@.TK2MSFTNGP10.phx.gbl...
> Tibor, no it doesn't. Only DBCC UPDATEUSAGE does it.
> --
> Paul Randal
> Dev Lead, Microsoft SQL Server Storage Engine
> This posting is provided "AS IS" with no warranties, and confers no rights.
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:evWisr$NEHA.3596@.tk2msftngp13.phx.gbl...
> run regularly).
> news:1715eae1.0405110654.460c627@.posting.google.co m...
>

How is sysindexes.rows updated by SQL Server?

I know that the rows column on sysindexes is not always accurate, and
that I can force and update by using DBCC UPDATEUSAGE, but I'm
wondering what happens "behind the scenes" so that this value is
eventually updated with the correct value.
The particular example that I'm working with is this: a developer
noticed that the rows property on the table pop-up in EM doesn't match
the actual row count. I explained to him why the values didn't match,
but I have to believe that eventually this value will be changed and
EM will report the accurate row count. Is this correct?
Thanks in advance!
MariaOne thing that corrects the value is DBCC CHECKDB (which I assume that you r
un regularly).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Maria Vogel" <vogelm@.meijer.com> wrote in message news:1715eae1.0405110654.460c627@.posting.
google.com...
> I know that the rows column on sysindexes is not always accurate, and
> that I can force and update by using DBCC UPDATEUSAGE, but I'm
> wondering what happens "behind the scenes" so that this value is
> eventually updated with the correct value.
> The particular example that I'm working with is this: a developer
> noticed that the rows property on the table pop-up in EM doesn't match
> the actual row count. I explained to him why the values didn't match,
> but I have to believe that eventually this value will be changed and
> EM will report the accurate row count. Is this correct?
> Thanks in advance!
> Maria|||Tibor, no it doesn't. Only DBCC UPDATEUSAGE does it.
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:evWisr$NEHA.3596@.tk2msftngp13.phx.gbl...
> One thing that corrects the value is DBCC CHECKDB (which I assume that you
run regularly).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
>
> "Maria Vogel" <vogelm@.meijer.com> wrote in message
news:1715eae1.0405110654.460c627@.posting.google.com...
>|||Ahh, thanks Paul. I didn't know that was changed since the old days (I still
recall 6.5, where only way to
adjust space allocation for syslogs was through CHECKDB...). :-)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
news:%23OrDTGFOEHA.1104@.TK2MSFTNGP10.phx.gbl...
> Tibor, no it doesn't. Only DBCC UPDATEUSAGE does it.
> --
> Paul Randal
> Dev Lead, Microsoft SQL Server Storage Engine
> This posting is provided "AS IS" with no warranties, and confers no rights
.
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote i
n
> message news:evWisr$NEHA.3596@.tk2msftngp13.phx.gbl...
> run regularly).
> news:1715eae1.0405110654.460c627@.posting.google.com...
>

How is sysindexes.rows updated by SQL Server?

I know that the rows column on sysindexes is not always accurate, and
that I can force and update by using DBCC UPDATEUSAGE, but I'm
wondering what happens "behind the scenes" so that this value is
eventually updated with the correct value.
The particular example that I'm working with is this: a developer
noticed that the rows property on the table pop-up in EM doesn't match
the actual row count. I explained to him why the values didn't match,
but I have to believe that eventually this value will be changed and
EM will report the accurate row count. Is this correct?
Thanks in advance!
MariaOne thing that corrects the value is DBCC CHECKDB (which I assume that you run regularly).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Maria Vogel" <vogelm@.meijer.com> wrote in message news:1715eae1.0405110654.460c627@.posting.google.com...
> I know that the rows column on sysindexes is not always accurate, and
> that I can force and update by using DBCC UPDATEUSAGE, but I'm
> wondering what happens "behind the scenes" so that this value is
> eventually updated with the correct value.
> The particular example that I'm working with is this: a developer
> noticed that the rows property on the table pop-up in EM doesn't match
> the actual row count. I explained to him why the values didn't match,
> but I have to believe that eventually this value will be changed and
> EM will report the accurate row count. Is this correct?
> Thanks in advance!
> Maria|||Tibor, no it doesn't. Only DBCC UPDATEUSAGE does it.
--
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:evWisr$NEHA.3596@.tk2msftngp13.phx.gbl...
> One thing that corrects the value is DBCC CHECKDB (which I assume that you
run regularly).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
>
> "Maria Vogel" <vogelm@.meijer.com> wrote in message
news:1715eae1.0405110654.460c627@.posting.google.com...
> > I know that the rows column on sysindexes is not always accurate, and
> > that I can force and update by using DBCC UPDATEUSAGE, but I'm
> > wondering what happens "behind the scenes" so that this value is
> > eventually updated with the correct value.
> >
> > The particular example that I'm working with is this: a developer
> > noticed that the rows property on the table pop-up in EM doesn't match
> > the actual row count. I explained to him why the values didn't match,
> > but I have to believe that eventually this value will be changed and
> > EM will report the accurate row count. Is this correct?
> >
> > Thanks in advance!
> > Maria
>|||Ahh, thanks Paul. I didn't know that was changed since the old days (I still recall 6.5, where only way to
adjust space allocation for syslogs was through CHECKDB...). :-)
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
news:%23OrDTGFOEHA.1104@.TK2MSFTNGP10.phx.gbl...
> Tibor, no it doesn't. Only DBCC UPDATEUSAGE does it.
> --
> Paul Randal
> Dev Lead, Microsoft SQL Server Storage Engine
> This posting is provided "AS IS" with no warranties, and confers no rights.
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:evWisr$NEHA.3596@.tk2msftngp13.phx.gbl...
> > One thing that corrects the value is DBCC CHECKDB (which I assume that you
> run regularly).
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > http://www.karaszi.com/sqlserver/default.asp
> >
> >
> > "Maria Vogel" <vogelm@.meijer.com> wrote in message
> news:1715eae1.0405110654.460c627@.posting.google.com...
> > > I know that the rows column on sysindexes is not always accurate, and
> > > that I can force and update by using DBCC UPDATEUSAGE, but I'm
> > > wondering what happens "behind the scenes" so that this value is
> > > eventually updated with the correct value.
> > >
> > > The particular example that I'm working with is this: a developer
> > > noticed that the rows property on the table pop-up in EM doesn't match
> > > the actual row count. I explained to him why the values didn't match,
> > > but I have to believe that eventually this value will be changed and
> > > EM will report the accurate row count. Is this correct?
> > >
> > > Thanks in advance!
> > > Maria
> >
> >
>

How is it possible that inserted and deleted are both empty in trigger?

I created manage update trigger to react on one column changes. There is an application which is working with DB, so I don't have access to SQL query which changes this column. In most cases trigger works fine, but in one case when this column changes, trigger is fired and IsUpdatedColumn is true for this column, but both inserted and deleted table are empty, so I can't get new value for this column. Any idea why is it happened? Is any way around?

This column type is uniqueidentifier. Inserted and deleted tables are empty when application is changing value from NULL to not null value, but if I change it myself from Management Studio inserted table contains right values. Most like problem is in query which is changing that value.

I'm doing that on Sql Server 2005.

Triggers are also firing when no rows is affected, it is fired on a per statement basis not per row.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

How is 'change' defined ?

Can anyone tell me how a change is defined when replicating ? in particular, if an update is done to an existing row, but the value is actually the same as it was originally, does this count as a change and will the replication attempt to update/resolve
it or not ?
I am working in a scenario where it is quite important to minimise the time/quantity of replication so want to minimise any unnecessary replicating. Are there any techniques I can use to help with this ?
any change is replicated.
|||Bother!
But thanks
|||Sarah wrote:
> Can anyone tell me how a change is defined when replicating ? in particular, if an update is done to an existing row, but the value is actually the same as it was originally, does this count as a change and will the replication attempt to update/resolv
e it or not ?
> I am working in a scenario where it is quite important to minimise the time/quantity of replication so want to minimise any unnecessary replicating. Are there any techniques I can use to help with this ?
Basically the log is replicated. So any action that will make a commited
change in the log will be replicated.
Furthermore, if you are doing updated, there is a possiblity that
inserts/deletes are replicated instead.
Typically, if you have a table with a unique index and you make an
update which update this index, sql server will replace your update by
an insert/delete and this is what will be sent to subscribers
|||Hi Sarah,
If you have a lot of updates that are setting columns to the same value
repeatedly, you can minimize the the replication volume by adding additional
"where" criteria to your update statements. For example, if you have a
statement (psuedo-code)
set @.val1 = 'XXX'
set @.tblKey = '123'
update TABLEX set fieldA = @.val1 where tblKey= @.tblKey
and you execute this 100 times, it will generate 100 updates, and 100
replication transactions.
If you add a where clause like so
update TABLEX set fieldA = @.val1 where tblKey= @.tblKey and fieldA <> @.val1
ii will not update the row after the first time. This type of clause
generally doesn't add much overhead to the transaction.
Ed
"Sarah" <anonymous@.discussions.microsoft.com> wrote in message
news:A8B78B80-4AF0-43FE-B3A8-8678C072C3E2@.microsoft.com...
> Can anyone tell me how a change is defined when replicating ? in
particular, if an update is done to an existing row, but the value is
actually the same as it was originally, does this count as a change and
will the replication attempt to update/resolve it or not ?
> I am working in a scenario where it is quite important to minimise the
time/quantity of replication so want to minimise any unnecessary
replicating. Are there any techniques I can use to help with this ?

How ineffcient is this cursor?

This cursor is a select on a large table. Each update occurs once for
each row. Does SQL hold all changes in memory on dirty pages until the
cursor is done (or check point is reached) and is this cursor pinning a
large table in memory?
while @.@.FETCH_STATUS = 0
BEGIN
while @.ldt_min <= @.ldt_max
Begin
update Deal_Details_ZN
set {some values}
from Deal_Details_ZN a, Temp_Zainet_Detail b
where a.Xkey = b.Xkey
select @.ldt_min = @.ldt_min + 1
end
Fetch next from Deal_Cur into @.ls_xkey, @.ls_zkey,@.ls_dealxref,@.ls_flowdate
End
Close Deal_Cur
Deallocate Deal_Cur"Shaun Farrugia" <far!!!!ugia!!!s@.dte!!!!ener!gy.com> wrote in message
news:eEgF9zrhDHA.2452@.TK2MSFTNGP10.phx.gbl...
> This cursor is a select on a large table. Each update occurs once for
> each row. Does SQL hold all changes in memory on dirty pages until the
> cursor is done (or check point is reached) and is this cursor pinning a
> large table in memory?
Cursors are inherently less efficient that set-based DML, but the way people
use cursors contributes to their slowness. Not wrapping your cursor-driven
DML in a transaction is a common performance problem that can degrade the
performance fo cursor-driven solutions from "ok" to "terrible".
Changing data in an RDBMS involves 3 basic steps. Editing the in-memory
data pages, writing log entries, and flushing the log entries to disk. Of
these, flushing the log entries to disk is the most expensive since writes
to the disk are slow and serialized.
A single DML statement is always atomic, so SQL Server will make all the
data page changes and write all the log entries first, and then flush all of
the log entries to disk at once. This is much more efficient than flushing
the log entries after each row. But when people write cursor-driven DML,
this is often exactly what they do, and it appears that it's what you're
doing.
If you wrap the whole loop in a transaction it will be more efficient
because the changes will be made to the in-memory structres, but you won't
have to flush the log to disk after each update.
David|||David thanks for your reply.
Is this cursor fully loaded in memory as a data structure the size of
the SELECT that the cursor is based on?
We are having problems where there are no free pages on the server and
this locks the server up. I am trying to determine the cause of the
failure and things like this are suspicious.
So in this situation, every update gets logged and flushed to disk at
each UPDATE statement? Would this cause an issue with memory? Or would
holding a transaction open until the cursor runs take up more memory?
David Browne wrote:
> "Shaun Farrugia" <far!!!!ugia!!!s@.dte!!!!ener!gy.com> wrote in message
> news:eEgF9zrhDHA.2452@.TK2MSFTNGP10.phx.gbl...
>>This cursor is a select on a large table. Each update occurs once for
>>each row. Does SQL hold all changes in memory on dirty pages until the
>>cursor is done (or check point is reached) and is this cursor pinning a
>>large table in memory?
>
> Cursors are inherently less efficient that set-based DML, but the way people
> use cursors contributes to their slowness. Not wrapping your cursor-driven
> DML in a transaction is a common performance problem that can degrade the
> performance fo cursor-driven solutions from "ok" to "terrible".
> Changing data in an RDBMS involves 3 basic steps. Editing the in-memory
> data pages, writing log entries, and flushing the log entries to disk. Of
> these, flushing the log entries to disk is the most expensive since writes
> to the disk are slow and serialized.
> A single DML statement is always atomic, so SQL Server will make all the
> data page changes and write all the log entries first, and then flush all of
> the log entries to disk at once. This is much more efficient than flushing
> the log entries after each row. But when people write cursor-driven DML,
> this is often exactly what they do, and it appears that it's what you're
> doing.
> If you wrap the whole loop in a transaction it will be more efficient
> because the changes will be made to the in-memory structres, but you won't
> have to flush the log to disk after each update.
> David
>|||Did you try re-writing the logic without a cursor?
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"Shaun Farrugia" <far!!!!ugia!!!s@.dte!!!!ener!gy.com> wrote in message
news:eEgF9zrhDHA.2452@.TK2MSFTNGP10.phx.gbl...
> This cursor is a select on a large table. Each update occurs once for
> each row. Does SQL hold all changes in memory on dirty pages until the
> cursor is done (or check point is reached) and is this cursor pinning a
> large table in memory?
>
> while @.@.FETCH_STATUS = 0
> BEGIN
> while @.ldt_min <= @.ldt_max
> Begin
> update Deal_Details_ZN
> set {some values}
> from Deal_Details_ZN a, Temp_Zainet_Detail b
> where a.Xkey = b.Xkey
> select @.ldt_min = @.ldt_min + 1
> end
> Fetch next from Deal_Cur into @.ls_xkey, @.ls_zkey,@.ls_dealxref,@.ls_flowdate
> End
> Close Deal_Cur
> Deallocate Deal_Cur
>|||No i just wanted to get an ide of what happens with memory consumption
with that particular cursor.
Tibor Karaszi wrote:
> Did you try re-writing the logic without a cursor?
>

Sunday, February 19, 2012

How i can download kb patch?

I have sql server 8.00.818
i know that the ultimate version is 8.00.993, and i'd like to update.
I microsoft i don't see anything.
I have legal SQL Server product.
Thanks in advance.
Juan Pablo.
jpcano@.gmail.comThe following has links to articles related to all of the
publicly available hot fixes post SP3a:
http://support.microsoft.com/kb/810185
Hot fixes that are not part of a security update require you
place a call to Microsoft support. The articles have
information on contacting support.
-Sue
On Tue, 08 Mar 2005 20:05:08 +0100, Juan Pablo
<anonymous@.microplft.com> wrote:

>I have sql server 8.00.818
>i know that the ultimate version is 8.00.993, and i'd like to update.
>I microsoft i don't see anything.
>I have legal SQL Server product.
>Thanks in advance.
>Juan Pablo.
>jpcano@.gmail.com

How grant all objects

How
grant user to tables(insert,update,delete,select),Sp,Func,Views !
in one line...
if can be...You'll need to do updates to the system tables, (I believe) and so you'll need to allow ad-hoc updates on those tables - normally not allowed.

However, and I know this is not what you're asking, but I like not giving any permissions on tables, and only giving exec permissions on Stored Procs. This way you protect your tables and you limit what can be done / seen in your database by defining allowed requests and actions in the procedures.