Public Synonyms vs. schema.object pattern

回眸只為那壹抹淺笑 提交于 2019-12-11 11:36:59

问题


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:

  1. I either need to specify the owner name before the objects. like SCOTT.EMP, or
  2. I can create public synonyms for all the objects that I'll be refering to.

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?


回答1:


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.

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, seems to have written a number of articles about this.

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.

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...



来源:https://stackoverflow.com/questions/10040486/public-synonyms-vs-schema-object-pattern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!