问题描述
在我的应用程序中,将有很多用户,超过500个.他们仅处理一个架构对象.我已授予必要的特权.当我说:
In my application there are going to be lots of users, over 500. They only deal with one schema objects. I've granted the necessary privileges. When I say:
SELECT * FROM EMP;
我收到表或视图不存在"错误,所以它表示:
I get the "table or view does not exists" error, so it means:
- 我要么需要在对象之前指定所有者名称.例如
SCOTT.EMP
或 - 我可以为将要引用的所有对象创建公共同义词.
我担心的是,如果公共同义词会影响具有大约300个同时连接的这么多用户,则其性能会受到影响.我应该选择第一种方法还是第二种方法?
My concern is, if public synonyms can have impact on the performance with this many users with an approximately 300 simultaneous connections. Should I choose the first or second method?
推荐答案
公共同义词具有非常特定的用途;它们使每个用户都能引用一个对象-假设它们具有适当的特权.如果将来您可能想要更改特定用户查看对象的方式,那么公共同义词就不可行了.
Public synonyms serve a very specific purpose; they enable an object to be referenced by every user - assuming they have the appropriate privileges. If at any point in the future you may want to change how a specific user views an object then public synonyms are not the way to go.
他们还用了整个数据库的特定对象名称.但是,存在公共同义词的事实并不妨碍您创建具有相同名称的对象.这令人难以置信.
They also use up a specific object name for the entire database. However, the fact that a public synonym exists doesn't preclude you from creating an object with the same name. This can be unbelievably confusing.
例如,假设您有一个过程test
和一个架构emp
.尝试执行emp.test
无效,因为您在表上已经有公共同义词emp
.
For instance, assume you have a procedure test
and a schema emp
. Trying to execute emp.test
will not work as you already have public synonym emp
on the table.
汤姆·凯特(Tom Kyte) ,似乎写了一个 关于此的文章数.
在性能方面,他们似乎建议在私有同义词上使用公共同义词会导致性能略有降低.但是,使用同义词代替不使用同义词也将导致性能略有下降.这表明,如果每一个 computron 都是珍贵的,则根本不要使用同义词.
On the performance aspect they seem to suggest that a public synonym over a private synonym will result in a slight decrease in performance. However, using a synonym instead of no synonym will also result in a slight decrease in performance. This suggests that if every last computron is precious you shouldn't use synonyms at all.
放在一起,我认为这意味着您应尽可能避免使用公共同义词.如果您需要一个,那么当然要使用一个,毕竟它们存在是有原因的,但是如果您不这样做,那么拥有一个又有什么意义呢? scott.emp
构造很清晰,可以准确地显示您所引用的架构和对象,而不会由您本人或其他刚接触数据库和代码的人引起误解.
Put together I think this means that you should avoid public synonyms if possible. If you need one then of course use one, they exist for a reason after all, but if you don't then what's the point in having one? The scott.emp
construct is clear, shows you exactly what schema and object you're referencing without any possibility for misinterpretation, either by yourself or someone else coming new to the database and code.
快捷点.您没有明确地说出来,但是问题的措辞似乎表明您正在为每个用户创建一个架构.看来这将极大地使人困惑...
Quick point. You don't explicitly say it but the wording of your question seems to suggest that you're creating a schema for every user. This seems like it would be massively confusing...
这篇关于公共同义词与schema.object模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!