l*b
2 楼
Hi, friends,
I will make some table replications between two DBs with same structure. The
main problem so far is how to prevent the PK conflict when replicating as
the current PKs are auto increased by sequence. My first thinking is the
have composite PK keys: instance id + auto increased, e.g. 01 and 1234 as a
PK pair, 01 is instance id and 1234 is current increased PK. I heard there
are some drawback in composite PK key, e.g. in ORM, etc. However, I am not
using ORM so far. Is my solution ok?
I will make some table replications between two DBs with same structure. The
main problem so far is how to prevent the PK conflict when replicating as
the current PKs are auto increased by sequence. My first thinking is the
have composite PK keys: instance id + auto increased, e.g. 01 and 1234 as a
PK pair, 01 is instance id and 1234 is current increased PK. I heard there
are some drawback in composite PK key, e.g. in ORM, etc. However, I am not
using ORM so far. Is my solution ok?
i*a
4 楼
Ms sql server? Replication takes care of pk automatically. In fact it
requires a pk for repl to work
requires a pk for repl to work
v*r
6 楼
I guess your concerns is that your target db is inserted not only by the
replication process, so the the target db sequence might clash with the
source db sequence.
The workaround is simple, modify your target db sequence to start with a
much higher value to ensure the source/target db sequences are using
different range.
Your thought will work but the problem is you are making your application un
-scalable by "instance id + auto increased".
replication process, so the the target db sequence might clash with the
source db sequence.
The workaround is simple, modify your target db sequence to start with a
much higher value to ensure the source/target db sequences are using
different range.
Your thought will work but the problem is you are making your application un
-scalable by "instance id + auto increased".
l*b
8 楼
Thank you, vbitter.
Could you advise me some examples of making your application unscalable by "
instance id + auto increased"?
un
【在 v*****r 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: I guess your concerns is that your target db is inserted not only by the
: replication process, so the the target db sequence might clash with the
: source db sequence.
: The workaround is simple, modify your target db sequence to start with a
: much higher value to ensure the source/target db sequences are using
: different range.
: Your thought will work but the problem is you are making your application un
: -scalable by "instance id + auto increased".
Could you advise me some examples of making your application unscalable by "
instance id + auto increased"?
un
【在 v*****r 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: I guess your concerns is that your target db is inserted not only by the
: replication process, so the the target db sequence might clash with the
: source db sequence.
: The workaround is simple, modify your target db sequence to start with a
: much higher value to ensure the source/target db sequences are using
: different range.
: Your thought will work but the problem is you are making your application un
: -scalable by "instance id + auto increased".
v*r
10 楼
Luckybb,
On second thought, I was wrong. Sequence helps you Apps scale better mainly
because it can be cached in memory. So as long as your sequence is defined
with CACHE option and you are inserting right after append "instance_id"
with "sequence number" on preparing PK value, there will be a little bit
more overhead in preparing PK value, but it won't affect your application's
scalability.
"
【在 l*****b 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: Thank you, vbitter.
: Could you advise me some examples of making your application unscalable by "
: instance id + auto increased"?
:
: un
On second thought, I was wrong. Sequence helps you Apps scale better mainly
because it can be cached in memory. So as long as your sequence is defined
with CACHE option and you are inserting right after append "instance_id"
with "sequence number" on preparing PK value, there will be a little bit
more overhead in preparing PK value, but it won't affect your application's
scalability.
"
【在 l*****b 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: Thank you, vbitter.
: Could you advise me some examples of making your application unscalable by "
: instance id + auto increased"?
:
: un
l*b
12 楼
thanks for quick and deep answer. Besides this generated PK, I am also
thinking one more solution to have composite primary key. I will have two
columns - instance_id and big int sequence number, then define them as a
composite primary key.
mainly
s
【在 v*****r 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: Luckybb,
: On second thought, I was wrong. Sequence helps you Apps scale better mainly
: because it can be cached in memory. So as long as your sequence is defined
: with CACHE option and you are inserting right after append "instance_id"
: with "sequence number" on preparing PK value, there will be a little bit
: more overhead in preparing PK value, but it won't affect your application's
: scalability.
:
: "
thinking one more solution to have composite primary key. I will have two
columns - instance_id and big int sequence number, then define them as a
composite primary key.
mainly
s
【在 v*****r 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: Luckybb,
: On second thought, I was wrong. Sequence helps you Apps scale better mainly
: because it can be cached in memory. So as long as your sequence is defined
: with CACHE option and you are inserting right after append "instance_id"
: with "sequence number" on preparing PK value, there will be a little bit
: more overhead in preparing PK value, but it won't affect your application's
: scalability.
:
: "
v*r
14 楼
Not a good idea. Having a separate instance_id column, you are adding
something that is totally irrelevant and redundant to your table entity.
something that is totally irrelevant and redundant to your table entity.
相关阅读
那里可以查询有关数据库原理的文档?Oracle SQL code question???????????????SQL Server 7.0 problem with mdt2g.dllhow to know how many uses exists in my db?WHY DB2的CONTROL CENTER出不来???请问如何将Mysql database里的数据转化到Access里?请问Oracle里布尔数据类型如何表示VB Excela newbie's question about oracleOne Q for DB expertMySQL数据库用户管理求助Oracle9i Database遇到sql 的日期型字段不会使用SQL2000XML questionpjones, do you know how to setup a encrypted multiprotocol in MSSQL?Can anyone Recommend a website for learning Oracle?How to move the tables to a schema in oracle?WebDBXML and JAVA[转载] Re: 谁有FILEMAKER 5 PRO 的安装码?