Published on

oracle foreign key primary key constraints performance tuning MTS IOT 9i block size backup rman corrupted column drop rename recovery controlfile backup clone architecture database archives export dump dmp duplicate rows extents segments fragmentation hot cold blobs migration tablespace locally managed redo undo new features rollback ora-1555 shrink free space user password link TNS tnsnames.ora listener java shutdown sequence

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. Limiting concurrent connections Administration TipsLimiting concurrent connections by UsersHaving Users make multiple connections to a database is a problem for a variety of reasons.Firstly, it chews up resources. Each connection acquires (in dedicated server mode, atleast) a Server Process and a PGA –which means each connection starts using up memoryand CPU cycles, even if the session itself is sitting their doing nothing very strenuous.Secondly, it’s a potential security issue: if a User is logged on 6 times, it is unlikely thatthey can be physically present at all 6 workstations simultaneously, which means the onesthey aren’t at are wide-open to abuse by passing disgruntled employees.It’s therefore a very good idea to limit the maximum number of concurrent connections aUser is permitted to make to a database, and the tool used to do that is the ResourceProfile, which has been around since at least Oracle 7.A resource profile allows the DBA to limit a number of things that a User can do –forexample, a maximum connection time can be specified (e.g., 480 minutes, or 8 hours), ora maximum idle time. But for our purposes, we can concentrate on the ability to limit thenumber of sessions a User is permitted to have running at any one time. That’s governedby a particular attribute of a resource profile, called SESSIONS_PER_USER.Every User has a profile already, even if you’ve never been aware of it, or made use of thefact. That profile is called ‘DEFAULT’, and is the one all Users acquire (by default!) whenfirst created, unless you specify another named profile.A quick solution to the concurrent connections problem would thus involve simply editingthe DEFAULT profile, like this:ALTER PROFILE DEFAULTSESSIONS_PER_USER 2;… and that would then prevent all Users from ever acquiring more than 2 concurrentsessions (although it will only take effect when they start re-connecting to the database).Note that there is no equals sign between the attribute name and its setting.A more subtle approach would be to allow some Users to make 3 connections, others tocreate 5. For that sort of discrimination, you’ll need to create your own profiles, like this:CREATE PROFILE BLAH3 LIMITSESSIONS_PER_USER 3;CREATE PROFILE BLAH5 LIMITSESSIONS_PER_USER 5;You then have to assign the right profile to the right user, like this:Copyright © Howard Rogers 2001 10/18/2001 Page 1 of 2
  2. 2. Limiting concurrent connections Administration TipsALTER USER FRED PROFILE BLAH3;ALTER USER MARY PROFILE BLAH5;… and so on.Next time Fred tries to log on multiple times, he’ll get the following error message on hisfourth attempt:ERROR:ORA-02391: EXCEEDED SIMULTANEOUS SESSIONS_PER_USER LIMITThere is one extremely important point to know about resource profiles, however: theytake no effect whatsoever until you switch them on. That is, even though they have beencreated, and properly assigned to all Users, no-one will have any connection limits untilyou tell the database to actually start enforcing the limits. That’s done with the followingcommand:ALTER SYSTEM SET RESOURCE_LIMIT=TRUE;That switches on profile limits for the duration of the Instance, and for new connectionsonly. A more permanent fix is to edit your init.ora, and enter the lineresource_limit=true there. That way, every time you bounce the Instance, you’ll findresource profile limit being enforced.(Incidentally, any sessions a User already has running when you assign him the new profileand switch resource limiting on with the ‘alter system’ command are counted against hisallowed total. So if a User already has 4 connections when you suddenly start limiting himto just 3, he will immediately not be able to make a fifth connection. However, theoriginal 4 are not disconnected, and are allowed to proceed as normal).Copyright © Howard Rogers 2001 10/18/2001 Page 2 of 2