Showing posts with label determine. Show all posts
Showing posts with label determine. Show all posts

Friday, March 23, 2012

Many to Many replication in sql server 2000

Hi

I'm trying to determine if it is possible to do many to many replication in sql server 2000.

What i basically want is to have n databases share the same basedate (share a common database) and allow updates in any database to be replicated to all the other databases (with a simple conflict resolution, like last update wins).

My goal is total autonomy, without a single point of failure. If any node goes down, the other nodes will continue to work and continue to replicate their data to the remaining nodes. When a node comes back up it will catch up with the over nodes (or get reinitialized if it was a serious crash).

The amount of data i want to replicate is not that big (less than 100MB) and does not change that often. All servers are sql server 2000 instances connected by a gigabit network and the number of nodes involved is less than 10. Some latency is also acceptable.

the question is: is this at all possible? I have read i bit in 'SQL Server High Availability By Paul Bertucci' and some other resources and it looks like a multiple publishers or multiple subscribers with merge replication setup should work, but i'm not too sure if it will work for n > 2 nodes (where all nodes publish and subscribe to each other) and it also mentions constraints on which data a given node is allowed to update (i hope this could be handled by simple conflict resolution).

And if it is not possible in 2000, could it be accomplished en 2005?

TIA Jens

Unfortunately you cannot do peer to peer replication you must have a publisher / subscriber model. You can have a cluster of servers at the center for availablilty in SQL 2005 i believe.

However one server (or cluster of servers) needs to be the master (publisher) and all the others subscribers.

Martin

|||

Martin_McNally wrote:

Unfortunately you cannot do peer to peer replication you must have a publisher / subscriber model. You can have a cluster of servers at the center for availablilty in SQL 2005 i believe.

However one server (or cluster of servers) needs to be the master (publisher) and all the others subscribers.

Martin


This was what i thought, but in the book i mention there is examples of a Multiple Publishers/Multiple Subscribers setups, where each node is both subscriber, publisher and distributer, to quote from the book (full book and figures available here):

Microsoft? SQL Server High Availability By Paul Bertucci wrote:

In the multiple publishers or multiple subscribers scenario, as shown in Figure 7.15, a common table (such as the Customers table) is maintained on every server participating in the scenario. Each server publishes a particular set of rows that pertain to it—usually via filtering on something that identifies that site to the data rows it owns—and subscribes to the rows that all the other servers are publishing. The result is that each server has all the data at all times, and can make changes to its data only. You must be careful when implementing this scenario to ensure that all sites remain synchronized. The most frequently used applications of this configuration are regional order processing systems and reservation tracking systems. When setting up this configuration, make sure that only local users update local data. This check can be implemented through the use of stored procedures, restrictive views, or a check constraint.


But i guess setting up multiple servers as both subscriber, publisher and distributer and letting them all subscribe to each other will cause havoc without the above mentioned constraints.

But i guess i'm not the first person to want this kind of setup and if it was possible i would have found some references somewhere on the net (i just did another search and found this article which describes what i'm looking for, but it is only for 2005 and when looking further into it, it does not support conflict resolution, which i think is required, guess we will have to build it ourselves if we really want it).

Best regards Jens

Wednesday, March 21, 2012

Many databases vs. 1 database

Hi,

I am trying to determine what the overhead is per database in SQL
Server 2000 Standard. I have the option to put several customers in one
database, or give each customer their own database. I would like to put
each customer in their own database to simplify maintenance and
strengthen security.

I have found the following document which shows the memory used by
various objects in SQL Server:

http://msdn.microsoft.com/library/d..._ar_ts_8dbn.asp

Based on this info I get the following *additional* memory requirements
per database:

Open Database (1 file, 1 filegroup): 6k
Open Objects (250 objects, 30 indexes): 692k
Total: 698k

Is this an accurate calculation of the overhead? Is there something
else that would affect the overhead that I am overlooking? Are there
any other downsides to having many databases versus a few databases?

Thanks,
MikeHi

Having 100's of databases does slow EM down as it need to list them all.
That is about it.

Regards
----------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

IM: mike@.epprecht.net

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/

<mike@.rumblegroup.com> wrote in message
news:1112124274.309091.156730@.f14g2000cwb.googlegr oups.com...
> Hi,
> I am trying to determine what the overhead is per database in SQL
> Server 2000 Standard. I have the option to put several customers in one
> database, or give each customer their own database. I would like to put
> each customer in their own database to simplify maintenance and
> strengthen security.
> I have found the following document which shows the memory used by
> various objects in SQL Server:
>
http://msdn.microsoft.com/library/d..._ar_ts_8dbn.asp
> Based on this info I get the following *additional* memory requirements
> per database:
> Open Database (1 file, 1 filegroup): 6k
> Open Objects (250 objects, 30 indexes): 692k
> Total: 698k
> Is this an accurate calculation of the overhead? Is there something
> else that would affect the overhead that I am overlooking? Are there
> any other downsides to having many databases versus a few databases?
> Thanks,
> Mike|||You said that you want to have many databases to simplify maintenance.
I'm not sure that I understand that. Especially with regards to change
control. With multiple databases you run the risk of one or more
databases becoming out of sync, either intentionally or
unintentionally. This can turn into a real headache if you aren't very
careful.

Also, will you ever want to research information on your customers as a
whole? You didn't include any information as far as what these
databases actually hold (this would have been useful to know), but
assuming that they hold sales data as an example... if you wanted to
find your total sales across all customers then you would have to
select across many databases. If you got a new customer you would now
have to change any queries that select across these databases to
include the new database.

Good luck,
-Tom.|||(mike@.rumblegroup.com) writes:
> I am trying to determine what the overhead is per database in SQL
> Server 2000 Standard. I have the option to put several customers in one
> database, or give each customer their own database. I would like to put
> each customer in their own database to simplify maintenance and
> strengthen security.

Putting all customers in the same database may be a good idea if
the customers does not access the data themselves.

But since you say "security", I assume that the customers will access
the databases.

One can handle security for customers in a shared database, so that
they only see their own data, but:

o If there is a slip somewhere, a customer can by mistake get access
to someone else's data.
o Even if correctly implemented, "Row-level security" is not waterproof,
since the views that typically implement such scheme can be provoked
to leak information.

And if the overhead of many databases are your only concern, there is
no reason for doubt. As Mike said, the overhead is negligible. You
will have to automate backups and all that, but that is not a major
issue.

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

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Thomas R. Hummel (tom_hummel@.hotmail.com) writes:
> You said that you want to have many databases to simplify maintenance.
> I'm not sure that I understand that. Especially with regards to change
> control. With multiple databases you run the risk of one or more
> databases becoming out of sync, either intentionally or
> unintentionally. This can turn into a real headache if you aren't very
> careful.

Version control and a automated way of propagating changes.

Note also that this cuts both ways. If you have one single database and
you want to upgrade from version 1.2 to 1.3 and big-whiz says no? Or what
of big-whiz wants special features that are useless to most other
customers? With one big database, how do you beta-test? And what if
you find that the server does not cut it anymore, and you want to
scale out? Move a bunch to another server, easy as a piece of cake
with multiple databases. The monolith is more difficult to deal with.

> Also, will you ever want to research information on your customers as a
> whole? You didn't include any information as far as what these
> databases actually hold (this would have been useful to know), but
> assuming that they hold sales data as an example... if you wanted to
> find your total sales across all customers then you would have to
> select across many databases. If you got a new customer you would now
> have to change any queries that select across these databases to
> include the new database.

Views with a whole bunch of unions can easily be build dynamically on
demand.

But I the most decisive factor in this question is security. A multi-
customer database is more or less destined to leak data among customers.
Whether this is acceptable or completely unacceptable could be different
from business to business case.

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

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

Monday, March 19, 2012

Manually determine execution plan?

Hi- is it possible (and does it ever make sense), to manually determine a
query execution plan, instead of letting the optimizer do it. There are
certain times, when I think "well, I [think I] know that the best place to
start would be with choosing all matching rows from table a, because this
will narrow down the query most quickly, and because there is a perfect inde
x
available on table a..." And sometimes, what I think does not appear to be i
n
line with what the optimizer seems to think...
If it's possible and it makes sense, how does one do it?
ChrisLook up "hints" in Books Online. You can "guide" the optimizer through the
use of hints in the FROM clause.
There are plenty of details in Books Online.
You can declare which indexes to use, how to acquire locks, etc. However,
you need to be really careful there and add hints only if you think the
optimizer fails to select the most efficient execution plan for a diverse
selection of cases - e.g. if the optimizer fails to use the indexes on an
indexed view and performs data retrieval from the base tables, you could use
the NOEXPAND hint in the from clause.
This is a big issue, so read up on it in Books Online before drastically
affecting any production processes.
ML
http://milambda.blogspot.com/|||You know, I had looked at hints and thought it couldn't do what I wanted to
do; but looking again, I can see that I can do it exactly with "force order"
and "index =". Thanks a lot, I think this should make a major difference.
Chris
"ML" wrote:

> Look up "hints" in Books Online. You can "guide" the optimizer through the
> use of hints in the FROM clause.
> There are plenty of details in Books Online.
> You can declare which indexes to use, how to acquire locks, etc. However,
> you need to be really careful there and add hints only if you think the
> optimizer fails to select the most efficient execution plan for a diverse
> selection of cases - e.g. if the optimizer fails to use the indexes on an
> indexed view and performs data retrieval from the base tables, you could u
se
> the NOEXPAND hint in the from clause.
> This is a big issue, so read up on it in Books Online before drastically
> affecting any production processes.
>
> ML
> --
> http://milambda.blogspot.com/|||One more question re this; is there any way to specify in which order the
elements of the "where" clause are applied? I don't see anything like this.
Though I suppose maybe I could make a bunch of subqueries and then use the
FORCE ORDER'
Chris
"ML" wrote:

> Look up "hints" in Books Online. You can "guide" the optimizer through the
> use of hints in the FROM clause.
> There are plenty of details in Books Online.
> You can declare which indexes to use, how to acquire locks, etc. However,
> you need to be really careful there and add hints only if you think the
> optimizer fails to select the most efficient execution plan for a diverse
> selection of cases - e.g. if the optimizer fails to use the indexes on an
> indexed view and performs data retrieval from the base tables, you could u
se
> the NOEXPAND hint in the from clause.
> This is a big issue, so read up on it in Books Online before drastically
> affecting any production processes.
>
> ML
> --
> http://milambda.blogspot.com/|||AFAIK the optimizer is free to choose any order "he" sees fit as far as the
WHERE clause is concerned. I hope you're not using WHERE for joins...?
ML
http://milambda.blogspot.com/|||No there isn't. But depending on your intentions, the CASE expression
could achieve what you want.
Gert-Jan
querylous wrote:
> One more question re this; is there any way to specify in which order the
> elements of the "where" clause are applied? I don't see anything like this
.
> Though I suppose maybe I could make a bunch of subqueries and then use the
> FORCE ORDER'
> Chris
> "ML" wrote:
>|||How to use a case in this situation? Wouldn't this result in running a query
twice. Let's say I have table with a date and a value, and I want to find al
l
rows between date range x-y and values a-b. I know that there are very few
entries between dates x and y, but there are many rows with values a and b.
So, I want to make sure the query checks the date first, instead of the valu
e
(very simple example). How would I control this with a case?
"Gert-Jan Strik" wrote:

> No there isn't. But depending on your intentions, the CASE expression
> could achieve what you want.
> Gert-Jan
>
> querylous wrote:
>|||The query below will always check the date column first, and will only
check the value column if the data column is within range.
However, the query will probably not be able to use an index because of
this (complex) expression.
SELECT ...
FROM ...
WHERE CASE
WHEN my_date_column BETWEEN x AND y
THEN
CASE WHEN my_value_column BETWEEN a AND b
THEN 1
ELSE 0
END
ELSE 0
END = 1
Gert-Jan
querylous wrote:
> How to use a case in this situation? Wouldn't this result in running a que
ry
> twice. Let's say I have table with a date and a value, and I want to find
all
> rows between date range x-y and values a-b. I know that there are very few
> entries between dates x and y, but there are many rows with values a and b
.
> So, I want to make sure the query checks the date first, instead of the va
lue
> (very simple example). How would I control this with a case?
> "Gert-Jan Strik" wrote:
>|||Chris,
Assuming that the query conditions are straightfoward ranges that
indexes can be used for, the column statistics on the table will
give the optimizer enough information to make the best choice.
When the optimizer makes the wrong choice, there are
a lot of possibilities. Here are a few.
The query may have been autoparameterized. If it was first
run with ranges that made one query plan good, then run again
with changes only to the range endpoints, the query plan may
not be reevaluated. A compiled/cached plan from the earlier
execution will be used, and the query will not run efficiently.
This is a common occurrence. Search these groups for
"parameter sniffing" and "recompilation" for information.
It may not be the wrong choice. A selective index is not always
the best thing to use. If it's not a covering index, for example, using a
more selective index may incur other query processing costs (bookmark
operations, nonsequential disk access) that outweigh the selectivity.
It may be the wrong choice, but because of reasons the optimizer
is unable to evaluate (correlated columns or other questions of
the actual, not statistical, distribution of data).
Without seeing the actual query, the table and index definitions, an
idea of the data distribution, and the query plans (the optimizer's
plan and the better plan that exists), it's hard to say what might
be going on.
It's worth pointing out that in SQL Server 2005, you have
somewhat more control over this behavior. The OPTIMIZE
FOR option can be used to tell the optimizer to use statistics
for values other than the actual parameters in query ranges.
Here's an example of the same query with two different OPTIMIZE FOR
clauses, where you can see different plans:
declare @.from datetime
declare @.to datetime
set @.from = '19970101'
set @.to = '19970401'
select *
from Northwind..Orders
where OrderDate between @.from and @.to
and Freight between 10 and 20
option (optimize for (@.from='19970101', @.to='19980101'))
select *
from Northwind..Orders
where OrderDate between @.from and @.to
and Freight between 10 and 20
option (optimize for (@.from='19980101', @.to='19980101'))
Steve Kass
Drew University
querylous wrote:
>How to use a case in this situation? Wouldn't this result in running a quer
y
>twice. Let's say I have table with a date and a value, and I want to find a
ll
>rows between date range x-y and values a-b. I know that there are very few
>entries between dates x and y, but there are many rows with values a and b.
>So, I want to make sure the query checks the date first, instead of the val
ue
>(very simple example). How would I control this with a case?
>"Gert-Jan Strik" wrote:
>
>

Friday, March 9, 2012

Managing Table Size

I have a table in my DB that I would like to restrict to recent records
only. Recent being the last 4 months. Can someone help me determine the
easiest and most maintenance free way to accomplish this?
Thank You
"Shawn" <skfabc@.yahoo.com> wrote in message
news:ezb1obNHEHA.3556@.TK2MSFTNGP10.phx.gbl...
> I have a table in my DB that I would like to restrict to recent records
> only. Recent being the last 4 months. Can someone help me determine the
> easiest and most maintenance free way to accomplish this?
> Thank You
Presumably you have a column with creation date included in the table
schema. In which case create a SQL Server Agent TSQL job that contains the
SQL:
DELETE *
FROM tablename
WHERE dateCol < GETDATE() - 120.
Schedule it to run regularly (e.g. every night). You might even want to add
it to the backup job.
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.647 / Virus Database: 414 - Release Date: 29/03/2004

Managing Table Size

I have a table in my DB that I would like to restrict to recent records
only. Recent being the last 4 months. Can someone help me determine the
easiest and most maintenance free way to accomplish this?
Thank You"Shawn" <skfabc@.yahoo.com> wrote in message
news:ezb1obNHEHA.3556@.TK2MSFTNGP10.phx.gbl...
> I have a table in my DB that I would like to restrict to recent records
> only. Recent being the last 4 months. Can someone help me determine the
> easiest and most maintenance free way to accomplish this?
> Thank You
Presumably you have a column with creation date included in the table
schema. In which case create a SQL Server Agent TSQL job that contains the
SQL:
DELETE *
FROM tablename
WHERE dateCol < GETDATE() - 120.
Schedule it to run regularly (e.g. every night). You might even want to add
it to the backup job.
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.647 / Virus Database: 414 - Release Date: 29/03/2004

Managing Table Size

I have a table in my DB that I would like to restrict to recent records
only. Recent being the last 4 months. Can someone help me determine the
easiest and most maintenance free way to accomplish this?
Thank You"Shawn" <skfabc@.yahoo.com> wrote in message
news:ezb1obNHEHA.3556@.TK2MSFTNGP10.phx.gbl...
> I have a table in my DB that I would like to restrict to recent records
> only. Recent being the last 4 months. Can someone help me determine the
> easiest and most maintenance free way to accomplish this?
> Thank You
Presumably you have a column with creation date included in the table
schema. In which case create a SQL Server Agent TSQL job that contains the
SQL:
DELETE *
FROM tablename
WHERE dateCol < GETDATE() - 120.
Schedule it to run regularly (e.g. every night). You might even want to add
it to the backup job.
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.647 / Virus Database: 414 - Release Date: 29/03/2004|||I agree with Bobs solution, but here is some SQL that will
find values greater than 4 months rather than 120 days
(although I am being very picky)
delete
FROM order
WHERE DATEDIFF(month, orderdate, getdate()) > 4
J
>--Original Message--
>I have a table in my DB that I would like to restrict to
recent records
>only. Recent being the last 4 months. Can someone help me
determine the
>easiest and most maintenance free way to accomplish this?
>Thank You
>
>.
>|||"Julie" <anonymous@.discussions.microsoft.com> wrote in message
news:1a22a01c41d4d$1f22acf0$a101280a@.phx.gbl...
> I agree with Bobs solution, but here is some SQL that will
> find values greater than 4 months rather than 120 days
> (although I am being very picky)
> delete
> FROM order
> WHERE DATEDIFF(month, orderdate, getdate()) > 4
LOL I was going to post that, but had a sudden doubt as to whether DATEDIFF
was TSQL or VB, couldn't check, so I chickened out.
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.655 / Virus Database: 420 - Release Date: 08/04/2004