问题
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:
- I either need to specify the owner name before the objects. like
SCOTT.EMP
, or - 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