Search code examples
sqloracle-databasebuffersas

SAS and Oracle error: ORA-04031


I am using an ORACLE db with SAS/connect. I recently implemented a change in my libname statement (a week ago) in which I added the following (don't know if related to issue):

insertbuff=10000 updatebuff=10000 readbuff=10000

Starting yesterday, I have been having an ORACLE issue when, after doing a

proc sql;
drop table oralib.mytable;
quit;

data oralib.mytable;
set work.mytable;
run;

I get the following error:

ERROR: ERROR: ERROR: ORACLE execute error: ORA-04031: unable to allocate 4160 bytes of shared memory ("shared pool","unknown object","sga heap(1,0)","modification "). With the occurrence of the above ERROR, the error limit of 1 set by the ERRLIMIT= option has been reached. ROLLBACK has been issued(Any Rows processed after the last COMMIT are lost).

  Total rows processed: 1001 
  Rows failed         : 1

It seems to happen randomly on any table of any size. Sometimes it will go through, sometimes (most of the times) it won't. Is there a shared pool release I should do from SAS?

Thanks for your help!


Solution

  • The shared pool is a memory structure on Oracle which keeps the following stuff:

    • data dictionary cache
    • SQL query and PL/SQL function result caches
    • storage for recently executed code in its parsed form

    It is possible to flush the shared pool, but this is not a good idea and I would not recommend it. What you have to do is size the shared pool of the database properly. Note that the shared pool is a pool for the entire Oracle instance - it is not on a per user base. So, if there are other users of the database, they might contribute the problem. I doubt that any particular query is the cause and I guess that the problem is that the shared pool is undersized.

    In case you have some DBA privileges granted for your user, you can check the current shared pool size by running the following query:
    SELECT * FROM v$sgainfo;

    You can increase the size of the shared pool with the following query
    ALTER SYSTEM SET SHARED_POOL_SIZE = 200M;

    Nevertheless, the best solution will be turn to the DBA managing the database (if there is such).