Sunday, March 30, 2008

Fun with Bind variables

Recently one of my fellow-colleagues was there at a client site where I had visited more than a year ago.

during my period of stay, I had pointed the developers about their lack of bind variables usage and why the plans suddenly change over night for no reason and it stays there in shared pool ..I remember having the same discussion with DBAs too and the DBA folks believed "alter system flush shared pool" is probably statement discovered to fix any SQL running longtime

Interestingly when I was casually talking with my colleague he mentioned that he noted that bind variable peeking had been turned off (note: underscore parameter, thanks to whichever DBA there). I was like "Hmm..someone wanted to have a short-cut way to solve everything without fixing the code"..

and interestingly over the next coupla days we discovered more issues..all sqls are going unoptimized because of bind variable being turned off..Initially when I was told it didnt strike me to relate..but then a quick test and peek into 10053 reveals it so clear..

without bind variable peeking, CBO had no clue about incoming values and so it didnt consider histograms - which is to an extent okay..but the bigger issue was it wont even look into partition statistics (think about it in a 24*7 system where u have so much data flowing in every single day and you have all partitions nicely build to partition the data at various physical segments)..CBO looks at table statistics and decides on plan (no partition pruning or elimination) - the plan is guaranteed to be wrong ..& to get it right you would have ensure global statistics should be perfect reflection of actual data.

you fix a small problem with a short-cut way..opened up another can of worms.. after all, most performance problems are man-made (well developers & dba made)

I mean ..I have to be thankful to all these folks who work so hard on keeping consultants like me in business..otherwise my living would be in a soup

so thanks folks..mess up more all you can.. sometimes it gets really interesting to see how far can you go that lane.:)

consider..but never code

I came across this interesting piece of code while I was actually looking for searching for something else.

Create or replace procedure <>...
merge into...

-- more merge statements ..followed by all condition checks


END <>;


Monday, March 10, 2008

SQL tuning ...

2008 = busy, very busy!

haven't had chance to blog much off late, thanks to the admirable maintenance window at my client place (starts at 12 midnight & goes till 2 or 3 am)

anyways I had bookmarked something interested (abt SQL tuning & Coding) I bumped into youtube longwhile ago and completely forgot abt it. Recently I see the same being referred & forwarded in oracle-list & got reminded.

here they are..enjoy!! (technology helps!! instead of typing pages..its so easy to just embed a video)