Skip to Main Content
  • Questions
  • Selectively purge the SQLAREA... terrible idea?

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, John.

Asked: July 21, 2016 - 3:26 pm UTC

Last updated: July 22, 2016 - 7:18 am UTC

Version: 12.2.4

Viewed 1000+ times

You Asked

Hi "Tom"-

We have an outside vendor's product hitting our database and never using bind variables. Every statement is unique. We can't change it, we're stuck with it.

This outside program is a very high volume. These constantly unique statements are literally pushing perfectly good but less used cached queries out of the sqlarea. The reports we only run once a month never have a chance to get reused, and these reports would run much faster if they used the shared pool. We have nothing in the sqlarea that hasn't been used in two weeks, by next month end the cache is gone. The shared pool is 20480 MB, if that matters. I don't know if that's huge or tiny.

These EDI pooled statements are very easy to identify, so I thought why don't we purge some of these before they push out what we want to keep? It seems you can purge selectively by address/has_value.

I thought writing a little maintenance program to run nightly and get rid of these cached queries using DBMS_SHARED_POOL.PURGE would solve the problem. The DBA says I'm nuts, and dangerous. Do you have a better idea? Just make the pool bigger? Pin the queries that are getting pushed out? I'm not a fan of pinning because what we DON'T need is way more obvious in the SQLAREA than what we might need. It's also a shorter list, the first half of the sql_text is always the same.

-John

and Chris said...

It's not ideal, but have you investigated setting cursor_sharing = force for the vendor's app?

You could set this in a login trigger. This way the rest of your database can continue to use cursor_sharing = exact and benefit from literals where necessary.

Presumably with all these unique statements the app isn't using bind variables at all. Which means it's almost certainly exposed to SQL injection.

Have you tried informing the vendor about the massive security hole in their application?

I'd look into these options before trying to write something that's constantly purging queries from the library cache.

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Alex, July 21, 2016 - 7:23 pm UTC

I'd be curious to know the metrics behind "and these reports would run much faster if they used the shared pool." I would expect the difference between a hard parse vs soft to be fractions of a second. Obviously the system as a whole would be greatly improved by bind variables, but I'm skeptical about how much time that would save on one individual query being cached vs not. If we were talking data blocks I feel like that would make much more sense.
Chris Saxon
July 22, 2016 - 7:18 am UTC

Yes, that would be interesting to know...

If the statements are complex and there's a lot of library cache contention (which it sounds like there is) the hard parse time could become "significant". But we'd need to see the parse time stats to know that.

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library