jump to navigation

Friday Philosophy – Inspirational Tweets: Why Do They Annoy Me so Much? December 11, 2015

Posted by mwidlake in Friday Philosophy, humour, Perceptions.
Tags: , ,
5 comments

A few weeks ago I saw this on the Twit Sphere:

A comfort zone is a beautiful place, but nothing ever grows there.

Wow. Deep. Meaningful. Let me follow that twitter account.

No. Let me not. I looked at the account and it was just an endless stream of “Inspirational Tweets” and very little comment or content. For some reason I can’t quite understand, this sort of thing gets on my nerves. No, that’s is not strong enough. It makes me unreasonably bad-tempered and angry. The first draft I wrote on this topic was a ranting diatribe of swear-words and invective {I love that word} that was completely beyond acceptable.

So I’ve been wondering, why do twitter accounts that put out lots of Inspirational Tweets annoy me so much? We have all seen them. In fact I have a couple of friends I follow on twitter who at times put out half a dozen Inspirational Tweets a day. I have to sometimes mute or “unfollow” them for a while. I think part of it is that if an account puts out half a dozen Inspirational Tweets a day, they can’t really mean them very much can they? If I had a set of short phrases that summed up important aspects of my life, such as “Always be nice to cats” then I can’t help but feel that they should be few in number and really mean something to me. They can’t really mean something to me if I have 200 of them.

Another reason is that so many of these Inspirational Tweets are actually just trite such as “when you listen, it’s amazing what you can learn” or even asinine such as “I love dramatically looking out windows on public transportation”. Yes, that is a real one. Of course, most of us put out some stupid tweets and we all have different tastes or interpretations of what is worth saying.

So I am not sure why I find them annoying – but I do. If you put out such tweets and I follow you & then unfollow you, follow you etc or I seem to go quiet (you might be on temporary mute) then just ignore it. I think it’s more my problem than yours. But you have annoyed me.

Why? Why follow me?

Why? Why follow me?

As a secondary rant of the day, I get really annoyed with these fake accounts that follow you or like a tweet of yours but having no connection to your world. Some of course are just another way of advertising something (usually soft porn it would seem – I usually spot them from the start as the account picture is some young women who can’t stop buying clothes 2 sizes too small and describes themselves as “bisexual and always follows back”…Yeah, I’m convinced). But recently I’ve had a lot of follows or likes from accounts, again apparently from young ladies, but now there are often two of them in the picture. Their tweet streams are just an endless flow of retweets, “clever” lines, the inspirational ones of course and nothing, not a thing where there is a conversation with someone else. But no soft porn. I can’t work out what these ones are actually aimed at. They don’t seem to be selling or promoting a specific thing, though they often have some films or makeup adverts retweeted, but if this is what they are selling, the content is drowned out by the stupid stuff and they are missing their audience. I’m pretty sure the content is generated though as I looked at a couple of them and the same quotes and “humorous” utterances seemed to make appearances across accounts.

If anyone could tell me if this is some type of advertising or it really is some attempt by teenage girls to increase they number of twitter friends just as a “look how many followers I have” (though I thought twitter was more an older persons thing) then I’m curious to know. It’s got to be sales, hasn’t it?

Perhaps I should stop worrying about these things and either mute or block them as them come up. Oh, I do🙂

Presentations & People, Friends & Fun, Whisky & Wet Laptops – UKOUG Tech15 December 10, 2015

Posted by mwidlake in conference, UKOUG, User Groups.
Tags: , ,
7 comments

Whisky?
Wet laptops?
I’ll get to them…

The UKOUG Tech15 conference ran earlier this week, from Super Sunday on the 6th through to the final sessions finishing at 16:20 on Wednesday 9th. In fact, I see on twitter that some people kept the fun going into Wednesday evening. I have to admit up-front my personal Bias – I was the database lead for the volunteers doing content and agenda planning. If you did not like anything about the Database stream content or how it was organised, please blame me and PLEASE either let me know direct or the UKOUG office. We can only try improve to things if we know they need improving.

UKOUG conferences suit everyone - at all levels

UKOUG conferences suit everyone – at all levels

So, having stated my bias, I actually thought tech15 was the best UKOUG Tech conference we have had in a few years. I feel this was helped by our return to the ICC in Birmingham as, for us old hands, it just felt like coming home. Also, the venue just works for us. Admittedly the spread of rooms over several levels can be a bit confusing for the new delegates & presenters, but you soon get used to it and the signage is pretty good (but I know we need to do better for some of the smaller Executive rooms hidden in what feels like the janitorial basement of a “Die Hard” movie – I love the irony that the “executive” rooms are in the least plush part of the place). Over the years we have worked out {mostly} how to make the space work best for us.

Just like the rooms, I feel the main conference works for people at all levels, just like my friend Svetoslav and I🙂. {for some reason people often want to take a picture of us two together…}. For the last two years we have specifically included introductory-level talks and aimed to suggest an introductory thread running through the conference. This year there was a thread for each and every stream. The idea is that if you already know your technical area, the topics of interest to you, and those speakers you feel talk to you then you are able to pick you talks quite easily (apart from the inevitable clash of 3 talks at the same time that are great – sorry!). The intro pathways are intended to help those who are new to the tech (or just that area), who cannot easily work out what is suitable or accessible. Plus, there is some importance to helping guide beginners to presenters who are easier to digest. Some presenters are technically very, very strong – but you need to actively listen rather than expect to be entertained.

Where are the bad guys,  Bruce?

Where are the bad guys, Bruce?

We kicked off with Super Sunday which was focused on more technically deep-down material. It was bigger than ever before and we had 7 streams, two on Database. I have to take my hat off to Brendan Tierney who was unable to get to Super Sunday on time – due to storms between Ireland & England on Saturday – but still managed to present! Mike Vickers on the Business Analytics committee swept into action, found a video of Brendan doing a similar talk elsewhere and made it happen. The session went well, I heard it was great to hear Brendan but not have to put up with him actually in the room🙂 {JOKE! He’s a good friend}. Super Sunday was fully booked well before the day, we had a great crowd and everyone seemed to really enjoy the event. I only heard good feedback – apart from one thing. How did we make the mistake of putting Connor McDonald in such a small room? Our bad, so sorry about that😦.

Getting back to the main conference, we had a Standard Edition stream this year, on Monday. We gave a full stream to this, 7 sessions, a big chunk of the Database content that day. It was a bit of a risk but when Joel Goodman suggested it at the planning kick-off meeting we agreed it was an area we ignored and felt there was a need for. Joel had been inspired by Jan Karremans, Philippe Fierens & Ann Sjökvist (of “SE Just Love It” fame) who had all started evangelising about it. Again, I heard great things about the sessions I did not get to, really enjoyed what I did and it seems we were serving a need in the community. So, doing what we should be doing as a user group, which is heartening. I actually think Oracle Corp is listening to the user community on this one and modifying its position, which is of course great for everyone.

Database Keynote

Database Keynote

I missed out on the conference keynote by Neil Sholay. I am allergic to conference-wide, oracle-business-direction talks. It would seem I should get over myself as I missed a cracking and insightful presentation. People I talked to said it was the best conference Keynote that had heard in a long while.

I feel I do have to mention two other sessions and those are the panel Q&A ones on the DB stream – I advertised them before the event and they were an Optimizer panel (by Jonathan Lewis, Maria Colgan, Chris Antognini and Nigel Bayliss – who is the new SQL Maria🙂 ) and the Database Keynote which was part presentation and then an open Q&A. Dom Giles & Maria Colgan took questions with their boss, Penny Avril, and these questions were totally unsighted. Some came from people before the session (and a big thankyou to the people at the curry the night before for adding *significantly* to that) and then the audience came alive and asked what they wanted. In both sessions Neil Chandler & I played “Dick and Dom” or “The chuckle brothers” maybe, putting forward the questions and trying to get to the audience members brave enough to ask at the time. I think by the end of the second session we almost knew what we were doing.

I won’t go into other sessions as I saw so many good ones and heard about many, many more. I asked around a lot and the general consensus is we had content people wanted across all sessions, streams and days. But please provide us with session feedback, it is very important to the speakers and the organisers.

quite a crowd wishing to try a dram

quite a crowd wishing to try a dram

The other side of conference is, of course, the social side. I spend as much time now out of sessions as in them, catching up with friend and meeting people I have never come across before or, the special joy of a conference, meeting someone in the flesh you previously knew only via social media, email or reputation. The best place to catch up with a lot of people is at the evening socials organised by UKOUG. This year a few of us added a “secret” element to the Community Drinks, which is that several of us brought along whisky to try. We know whisky (or even alcohol) is not everyone’s taste but it was just a bit of fun, an extra dimension to everything else on offer. And boy it worked. It got crowds around the tables and then others with no interest in the whisky came to chat to the crowds and it was all very amiable. The only “problem” was, so many of use brought along a bottle (or even two) that we had something like 18 whiskys {from all over Scotland as well as Irish and Welsh). The idea came from and was done by the community, to benefit the community, which is just perfect “User Group”. I’m going to acknowledge Thomas Presslie & Neil Chandler for that.

The Irish was popular, but not the JW Red Label?

The Irish was popular, but not the JW Red Label?

As well as the organised UKOUG social events there are plenty of people going of in smaller or larger groups to have a meal or sit around a table in a quieter pub, which is where you get to really know people. I wish I could do more of that, but with only 3 days I inevitably get to the end of the conference and think “I never had a nice pint with X… or Y… or….” well, enough for a couple of goes through the alphabet. I try and do more by hanging about in the hotel bar but that can be a dangerous thing to do! Even though I established a reputation for having a Nice Cup Of Tea at around 11pm.

Then there is the final part of conference for me. I’m there to help. All of us on the committees, the UKOUG volunteers and of course the UKOUG staff are there to try and make sure presenters and delegates alike have a good experience. Some presenters, like Zahid Anwar, Mike Dietrich, Chris Lawless and Chris Saxon step in with only a couple of weeks or less to fill a hole in the agenda that opens up. Some people will even step in to provide a talk at the drop of a hat. And we nearly had that this year in three incidents I know of directly. The first I already mentioned, with Brendan being replace with a video of himself. But we had someone we could have asked if the video did not work out. Zahid lost his laptop en-route and had to chase it across the train lines of the Midlands. He contacted me and I pre-warned people we might need to do a quick swap, but got in just in time. As for Chris…

Chris Saxon came over to me about 16:00 on Tuesday. “Hmm, I have a bit of an issue. My laptop got wet and has stopped working”. Chris was not doing a normal presentation, he was doing demonstrations. We fired up his damp laptop and it could not see his disk. So I looked up the local Maplins and sent him that way and I went to my hotel and got my own laptop. We managed to take his disk out the laptop and put it in an external caddy, via which I could see the contents when we plugged it into my machine. After messing with permissions we got the bare necessities over to my machine and then Chris worked his magic to make his “SQL Magic” session work on this foreign machine. He was very grateful, which is nice, but it’s sort-of what we are there for. I want him to be able to present and you guys & gals to see it. So I was more than happy to help it happen.

The one downer was that I now had to be there early Wednesday morning before his session, to get my laptop to him and allow him a final test. That would have been fine if I had not been naughty and stayed out way too late Tuesday night. I did not get anything like enough sleep before I got up a bit too late and rushed over to the room he was presenting in. But it happened and, I have to say, Chris was remarkably calm and organised throughout the whole experience.

BTW for anyone who was in the actual session and saw me “storm out” when he slagged off my machine – he knew I was going to pop out. I was “a bit tired” from the night before and had not even sipped a cup of tea, so I had to get something to eat/drink or fall over. I did come back and take my seat again but I know a couple of people thought I had thrown my toys out my pram🙂

It was a great conference. I can’t wait for UKOUG TECH16. Next December. In the Birmingham ICC.

Friday Philosophy – Sex in The Office December 4, 2015

Posted by mwidlake in Friday Philosophy, Perceptions.
Tags: , ,
11 comments

Sex in the office. It’s a bad idea – you can get hurt falling off the swivel chair or desk and there is the ever present danger of the stapler…

Though accurate, the title is of course misleading to make you look at this blog. I’ve actually been thinking about the ratio of women to men in the office, the impact it has and the efforts put in to address it. If you have somehow missed it there is something called “WIT” – Women in Technology – and it is part of an ongoing drive to get more women into the traditionally male-dominated careers in Science, Technology, Engineering and Mathematics {STEM} and to help them stay there once they are in the industry. I can’t say I’ve been aware of this next aspect until the last couple of years but apparently a women is more likely to move out of IT as they get older than a man is.

There is a morning meeting on WIT at the UKOUG Tech15 conference on Tuesday at 8pm (details here) and it is open to men as well as women. I hope to be there as it is a topic I am interested in and support. However, I have to say I have some ambivalence towards it too. Why? Because at some of these meetings you get a bit of “men-bashing” and also things get suggested which are positive discrimination – and I am not a fan of discrimination, even when you put the word “positive” in front of it.

I work in the UK and I’ve worked in IT now for 25 years. The ratio of women to men in technical roles does not seem to have changed much in most of that time and has stayed at around 10% to 20%, depending on the business area. My first job was in the national health service and the percentage of women was about 20%. I’ve also been in teams where there is not a single woman. I much prefer there to be a higher percentage of women where I work than 10% – and this is not for any creepie “they are more pretty” or similar reasons, it is because when it is all or mostly men, the atmosphere is like a never-ending boy’s locker room. Juvenile humour, constant swearing and biological jokes are good fun for a while, but not day in, day out. Rightly or wrongly, when the sex ratio is more balanced, so is the humour and behaviour. I’m told women are just as bad when they are in a male-free environment – but I would not really know, would I?

I think over the last 5-10 years there has been some movement though, I think we are finally moving towards a more balanced ratio. Actually, no , it would be more accurate to say we are progressing to a less unbalanced ratio.

There is no question about the technical ability of women and I am confident in my own attitude towards having women in technical roles – I’ve hired, promoted, supported and reprimanded enough women over the years to demonstrate I don’t have any issues there. But I don’t think we will ever have equal numbers of men and women across the technical roles in IT.

Why do I think this? Because it is about numbers, percentages and factors. I have to quickly point out that I am not talking about individuals here and there are individual exceptions to everything I say, but I do run the risk of upsetting people…

One factor is the Autistic spectrum. Or maybe I should be saying Aspergers, as that term was supposed to indicate people with reduced empathy but not reduced cognition (intelligence or learning speed). I was talking to a friend about this a few days ago, the fact that when you look at people working in IT there is a tendency towards us being poor at understanding people, uncomfortable dealing with other humans and being happier working with things. ie somewhere in the mild end of the  Autistic spectrum. Obviously this is not true of everyone in IT and probably is only relevant to, ohhh, 83% of us {Joke! It is probably less than 50%}. It is certainly true of me and a few of my best friends, ironically. Technology particularly appeals to those of us who are on that spectrum, especially when we are younger, as it is easier for us to deal with something other than people. It is also true that you are less likely to be somewhere on the autistic spectrum if you are a woman than a man. Add those two together and over a large enough sample, like the working population, you will see a significant effect. Men as a population are more autistic, IT appeals to the autistic, you will get a bias towards men in IT. It does not mean all men in IT are autistic.

Another factor is of course that when children come along it is nearly always the woman who takes the lead in childcare. It does not have to be that way, it certainly should not be expected let alone forced. I’ve known couples where the father stops work and takes the main parental role (and they always run up against a lot of sexism about that, so it’s a two-way street ladies!) but it is still relatively rare. And taking time off work has an impact on career development and skills because you are not doing the job during that time. I know that when I have not done something for a year or two my skills degrade (I did not do much PL/SQL development work for a couple of years and I was rusty as heck when I went back to it properly). What is wrong is the tendency for that pause in development to be continued when people come back to work or work part time. We can help address that by making more effort to support people (women and men) coming back to work to continue onwards from where they left off, not be expected to stay still. But, over the whole industry, taking a break to concentrate on family is going to have an impact on not only the raw numbers of women in IT at any time but also career progression relative to age. Again, I stress this is not about individuals, it is about ratios and percentages.

Another aspect is that if you have a break from what you do as a career, it is an opportunity to ask yourself if you still want to do it. If you don’t have a break you are less likely to question your job and more likely to just keep turning up and doing it. Some women drop out of IT due to sexism – but some drop out as they just decide to try other things. On average men are less likely to have such a break and just trudge on, week-after-week, year-after-year.

There are other factors beyond those three but the point I am making is that I don’t think the ratio between women and men in technical roles will ever be 50:50. I would prefer it to be 50:50 but I don’t think it will be. I am also not arguing in any way about being complacent about sexism at work, not promoting women or anything like that. The fact that I don’t think we will ever have parity of numbers does not condone sexism in any way. Everyone should have the same chances and support. I’d like there to be no need for positive discrimination as we don’t have any discrimination – it is all about the individual and ability. As my friend Pete Scott put it on twitter when this post first went up – Humans In Technology is where we want to be – HIT

UKOUG_Tech15 – One Last Big Conference to Round Off 2015 and it’s a Cracking One December 2, 2015

Posted by mwidlake in conference, UKOUG, User Groups.
Tags: , ,
add a comment

It is December so it must be time for the UKOUG annual Tech conference. And it is! It is being held from Monday 7th December to Wednesday 9th December at the ICC in central Birmingham, UK. You can see full details here at their main website. It is taking place at the same time and location as the Apps15 and JDE15 conference. Of course, I am both blessed with inside knowledge and biased as I have helped with the organisation this year, specifically on creating the database stream content. But I am sure this year, on it’s return to the conference spiritual home of Birmingham, it’s going to be the best Tech15 conference in years.

You can still register for the event. If you or your organisation have UKOUG membership and you have not registered yet, you are really missing out. If you are not a member, you can still register and pay for the conference alone – or join the UKOUG membership at a level where conference passes are included which makes way more sense. Information can be found at this link

If technical content is your thing, you might still be able to register for Super Sunday {Update – Super Sunday is now fully subscribed, but you can ask to be on the waiting list}, which is free if you are registered for the main event. Details can be found here but in summary it is a 7-stream afternoon of deep dives into database, development, APEX, Business Analytics and Integration topics with speakers such as Connor Mcdonald (half of the new Ask Tom – how many slides will he cover?), Mark Rittmam of Rittman Mead fame, Luca Canali from CERN, Product manager of PL/SQL and EBR Bryn Llewellyn (with guest appearances by Jonathan Lewis and Stewart Ashton)… Basically, lots of good stuff.

Not just this bunch of ACE's and ACEDs...

Not just this bunch of ACE’s and ACEDs…

There is of course lots of technical content in the main Tech15 conference and a whole host of top presenters – and also new presenters, some of whom are sure to become the big names of future years. As a User Group, the whole aim is to grow the knowledge and expertise of every member of UKOUG.

I just can’t pick names from the list for the main conference so I’ve stolen an impressive tweet put out by Sten Vesterli about the number of Oracle ACEs and ACE Directors who are presenting at Tech15. I did a quick count and it looks like about 58 to me!

You might be more interested in the official word from Oracle as to the direction of the company and the technology. We have lots of presentations by Oracle themselves, the conference keynote by Neil Sholay on Re-imagining the role of IT for Digital, and technical keynotes for all of the specific streams. I’ll make a special call out for my “own” database keynote, which is something special this year. Dominic Giles, Penny Avril and Maria Colgan will give a review of What’s New and then take questions – any questions – from the floor. No questions placed by them, real questions. You can see details (and how to submit questions) at my blog post about it here.

There is also the Exhibition Hall where we have something like 60 exhibitor, all happy and willing to show you what services and solutions they can offer you. And a free pen🙂. This is where we all gather for coffee and lunches and mingle with exhibitors and attendees alike.

I’ve been going to the UKOUG Tech conference for well over a decade now, I have only missed it once in that time (and that was for a Significant Milestone Holiday) and I go for 2 main reasons:

  1. The technical content I have mentioned already.
  2. The social side.
but all of this bunch too

but all of this bunch too

Tech15 is a huge conference for a user group with several hundred people there –  and yet there will be a hundred plus people there I know. It is such an established and friendly group that though I meet some people only at the conference each year they have become good friends. For me personally, this is now the main point of the conference, but then I guess we all have different things we want to get out of the event.

The social side is very important. On Monday evening there is the  Community drinks. This is where there will be people from each of the SIG (Special Interest Groups) run by UKOUG to talk to you about their party of the community and give you a beer, wine or soft drink. There are rumours that some whisky tasting will be on offer….

After the Community Drinks most people head out to one of the many bars or restaurants around the conference centre. You will find a crowd in All-Bar-One or one of the other places over the bridge from “the back” of the conference centre. Later on you may well find a bunch of people in the bars of the larger hotels.

On Tuesday we start with Exhibition Drinks in the exhibition hall for an hour or so and then there is the Big Birmingham Bash – from 18:45 until late with various entertainments, drinks and food. We join up with Apps15 and JDE15 for this. Again, if this is not enough for you then you and your friends can move on to the surrounding bars and restaurants after.

I’m really looking forward to the event and meeting lots of old friends there, as well as people I only know virtually who are managing to get to the conference this year. I’ll be there from Sunday, I know I will learn a lot over the four days, have a good time and probably stay out too late. I’ll be worn out by Wednesday – but it’s worth it.

A Different Type of Keynote & Jonathan Lewis Panel Session at UKOUG Tech15 November 27, 2015

Posted by mwidlake in Presenting, UKOUG, User Groups.
Tags: , , ,
2 comments

Technical people tend not to enjoy Keynotes at conferences. We are allergic to content-light “there has never been a better time to invest in our products” fluffy, frou-frou, big picture talks. We want how-it-works meat on the bones of what is served up to us.

OK, it's a very poor photo but the best I have of Dom presenting. Sorry Dom.

OK, it’s a very poor photo but the best I have of Dom presenting. Sorry Dom.

Well, at the UKOUG Tech15 conference this year (Birmingham ICC 7th-9th December) we have a treat for you – The Database stream keynote is technical AND you get to ask whatever questions you want – questions about Oracle RDBMS technology that is.

Dominic Giles, Maria Colgan and Penny Avril have agreed to be up on stage and, after the first half telling us about some of the things introduced at Oracle OpenWorld 2015, they will take questions. Questions they do not know are coming. Real questions. From people at the conference. Your questions. These are not questions that have been placed by them or checked with them before hand.

Dom does this at smaller user groups; he stands up and asks for any questions from the audience and he just tells it the way he sees it. His incredible knowledge of the product is matched only by his humour (so no huge expectation for you to live up to there, Dom!). Maria and Penny are similarly endowed with knowledge and great presentation skills and are willing to give this a go for us. Brave people.

{I think in the photo Dominic has just been asked about why something in Oracle does not work – and he’s trying to decide whether or not to kill the person who asked…}

You will be able to ask questions on the day, at the session, but you will also be able to post questions at the UKOUG information desk on Monday and I am happy for you to send me any questions you have (mwidlake@btinternet.com or leave a comment on this blog – I don’t think Maria, Dom or Penny drop by here very often so they won’t see them…:-) ). Of course, there is no point asking a question if you do not intend to be at the conference and at that session!

Having run similar sessions to this at smaller events, I know that you need some questions to get the ball rolling and then, with a little luck, the audience warms up and asks questions. The key thing is, no matter the source, the panel do not know the questions before-hand. I’ve seen sessions like that, with placed questions, and it just comes over as fake.

Why did I mention Jonathan Lewis? Well, on Monday at 11:20 he is doing another panel session taking questions, with Nigel Bayliss, Christian Antognini and Maria Colgan (again – we work them hard). This session is focused on the Cost Based Optimizer. We already have enough initial questions but if you are curious about the optimizer and performance, maybe ask your own question from the floor, it’s a must-see session. Jonathan talks about this session in this blog post.

So at UKOUG Tech15 you have two panel sessions in the database stream where you can ask questions. We also have several “Roundtable” sessions across the whole agenda which are perfect for asking questions too. If you have never been to one, a Roundtable session is more a discussion in a smaller group, with one or two experts “officially” there as well as usually some unofficial experts in the crowd. Panel session are “pose your question, get expert answers”, roundtables are more interactive, more like a conversation in the bar. They can get quite lively (but fights are rare)🙂.

All in all, we are aiming for a good dose of interaction between presenters and delegates. And never forget, most of us presenters are more than happy to chat and answer questions throughout the conference. Just don’t ask hard questions if you meet us in the evenings, when we are half-drunk…

Pragma UDF – Some Current Limitations November 11, 2015

Posted by mwidlake in performance, PL/SQL, SQL, Testing.
Tags: , , , ,
7 comments

There are currently some limitations to when pragma UDF will speed up your calls to PL/SQL functions from SQL.

In my post introducing the new pragma UDF feature of Oracle 12c I explained how it can be used to reduce the impact of context switching when you call a PL/SQL function from SQL.

In my example I showed how running a SQL-only SELECT statement that formatted a name for display over 100,000 records took 0.03 seconds went up to 0.33 seconds when the formatting SQL was put in a user defined PL/SQL function. This impact on performance is a shame as it is so beneficial to encapsulate business logic in one single place with PL/SQL. Stating that the PL/SQL function is a user defined one with the pragma UDF option reduced the run time to 0.08 seconds – which is removing most of the context switching overhead. Check out the prior post for full details.

This improvement in performance is great news and is as good, and sometimes better, than using the other new capability of 12c – allowing you to state a function as part of a SQL statement using the WITH clause, if you know about that (I plan to do a further post on that). As a quick example, here is my display name function code expressed within a WITH clause:

with 
  function l_disp_name(p_sn      in varchar2
                      ,p_fn1     in varchar2
                      ,p_fn2     in varchar2 :=null  
                      ,p_title   in varchar2 :=null )
return varchar2
is
v_return     varchar2(1000);
begin
  v_return := case when p_title is null then ''
                   else initcap(p_title)||' '
              end
            ||initcap(p_fn1)||' '
            ||case when p_fn2 is null then ''
                   else substr(p_fn2,1,1)||' '
              end
            ||initcap(p_sn);
return v_return;
end l_disp_name;
select  max(l_disp_name(p_sn =>surname           ,p_fn1  =>first_forename
                       ,p_fn2=>second_forename   ,p_title=>pers_title)        ) text_output
       ,count(*)
from pers
/

The above runs in 0.10 seconds, just slightly slower than 0.08 for my pragma UDF function

However, I need to warn you of some current limitations to pragma UDF. Nearly all the examples on the web so far are

  • using very, very simple functions that take in a number and return a number
  • Use a stand-alone stored function

And they work fine. However, I had real trouble getting a performance gain when I was working with my function that took in four varchar2 inputs and returned a varchar2 value. No error was given when I marked the function with pragma UDF but there was no performance gain (or loss).

I eventually worked out some limitations to pragma UDF on my version of Oracle – 12.1.0.2.0

  1. It gives a performance boost when the inputs and return values are NUMBER, VARCHAR2, multiple VARCHAR2 IN parameters
  2. There is no performance boost when either or both the IN parameter or RETURN value is a DATE
  3. There is no performance boost if there are any default values for VARCHAR2 IN parameters
  4. If the function gains a performance benefit from pragma UDF as a standalone stored function, it appears to also gain an advantage if it is a function defined as pragma UDF within a package – so you can still keep all your functions in packages.

You might notice that my example of using the WITH clause states a function that has default values. The WITH option gains the performance advantage of that feature just fine with IN parameter defaults.

The take-home message is that, at present, pragma UDF only seems to help functions with certain types of IN or RETURN values and is nullified by default values – so if you see no performance gain for your functions, this might be why. I need to stress that my tests were not exhaustive, I have not investigated many other combinations.

I’ve discussed the issue with a couple of people within Oracle and the relevant Product Manager is looking to investigate further for me, which is jolly decent of the fellow.

My investigation is of course only by empirical testing, it does not reveal how pragma UDF works. But, as I said in my first post, it seems to aid how information is passed between the PL/SQL and SQL engines as it is variation in those that seem to nullify the benefit of pragma UDF. If you want to duplicate my tests, you can do with the below scripts. I show my test output first, with comments produced with PROMPT commands. I then give you the SQL to create the test table, the functions and package I used and the test script. Feel free to take, expand and let me know of anything different or further you may find. I say nothing of interest after the scripts, so this is in effect the end of the post🙂

The output of my test, with prompts:

running udf_tests
investigating why pragam udf helps some simple functions and not others
---------------------------------------------------------------------- --

simple number in-number out function
NUMBER_OUTPUT   COUNT(*)                                                                            
------------- ----------                                                                            
  10000000000     100000                                                                            
Elapsed: 00:00:00.12

NUMBER_OUTPUT   COUNT(*)                                                                            
------------- ----------                                                                            
  10000000000     100000                                                                            
Elapsed: 00:00:00.03
** udf helps

simple varchar in-varchar out function
TEXT_OUTPUT                      COUNT(*)                                                           
------------------------------ ----------                                                           
XYYYY                              100000                                                           
Elapsed: 00:00:00.12

TEXT_OUTPUT                      COUNT(*)                                                           
------------------------------ ----------                                                           
XYYYY                              100000                                                           
Elapsed: 00:00:00.04
** udf helps

two varchar in-varchar out function, is the issue with more than one in parameter?
TEXT_OUTPUT                      COUNT(*)                                                           
------------------------------ ----------                                                           
XYYYYYYYYY                         100000                                                           
Elapsed: 00:00:00.14

TEXT_OUTPUT                      COUNT(*)                                                           
------------------------------ ----------                                                           
XYYYYYYYYY                         100000                                                           
Elapsed: 00:00:00.04
** udf helps

simple date in-date out function
DATE_OUTPUT            COUNT(*)                                                                     
-------------------- ----------                                                                     
14-MAY-2010 13:11        100000                                                                     
Elapsed: 00:00:00.15

DATE_OUTPUT            COUNT(*)                                                                     
-------------------- ----------                                                                     
21-NOV-2004 13:11        100000                                                                     
Elapsed: 00:00:00.15
***************************************************************SIMILAR TIME!!!
udf does not help

is date out the issue,  date in-num out function
NUMBER_OUTPUT   COUNT(*)                                                                            
------------- ----------                                                                            
      2454431     100000                                                                            
Elapsed: 00:00:00.17

NUMBER_OUTPUT   COUNT(*)                                                                            
------------- ----------                                                                            
      2454231     100000                                                                            
Elapsed: 00:00:00.18
***************************************************************SIMILAR TIME!!!
udf does not help

is date in the issue,  num in-date out function
DATE_OUTPUT            COUNT(*)                                                                     
-------------------- ----------                                                                     
07-AUG-2018 18:11        100000                                                                     
Elapsed: 00:00:00.21

DATE_OUTPUT            COUNT(*)                                                                     
-------------------- ----------                                                                     
11-NOV-2015 17:57        100000                                                                     
Elapsed: 00:00:00.21
***************************************************************SIMILAR TIME!!!
udf does not help

so back to my original function I had issues with
a difference with the multiple vcs in func and my orig func is my orig had defaults
thus I will try a version with no defaults
TEXT_OUTPUT                      COUNT(*)                                                           
------------------------------ ----------                                                           
Ms Wyyyyyyyyy W Wyyyyyyyyy         100000                                                           
Elapsed: 00:00:00.19

TEXT_OUTPUT                      COUNT(*)                                                           
------------------------------ ----------                                                           
Ms Wyyyyyyyyy W Wyyyyyyyyy         100000                                                           
Elapsed: 00:00:00.08
****************************************************************UDF has an IMPACT

now with one of the parameters set to a default
TEXT_OUTPUT                      COUNT(*)                                                           
------------------------------ ----------                                                           
Ms Wyyyyyyyyy W Wyyyyyyyyy         100000                                                           
Elapsed: 00:00:00.32

TEXT_OUTPUT                      COUNT(*)                                                           
------------------------------ ----------                                                           
Ms Wyyyyyyyyy W Wyyyyyyyyy         100000                                                           
Elapsed: 00:00:00.32
****************************************************************UDF has NO IMPACT
****************************************************************ALSO defaults cause both versions to be slower

now call the simple disp_name_udf function that benefits standalone from within a package

standalone
TEXT_OUTPUT                      COUNT(*)                                                           
------------------------------ ----------                                                           
Ms Wyyyyyyyyy W Wyyyyyyyyy         100000                                                           
Elapsed: 00:00:00.08

within package
TEXT_OUTPUT                      COUNT(*)                                                           
------------------------------ ----------                                                           
Ms Wyyyyyyyyy W Wyyyyyyyyy         100000                                                           
Elapsed: 00:00:00.08
*********************************************** WORKS - so long as neither spec of body have prm defaults

and just to round of, using a subquery factored function which my prior tests showed reduced overhead
TEXT_OUTPUT                      COUNT(*)                                                           
------------------------------ ----------                                                           
Ms Wyyyyyyyyy W Wyyyyyyyyy         100000                                                           
Elapsed: 00:00:00.10

the WITH function benefits even with defaults
TEXT_OUTPUT                      COUNT(*)                                                           
------------------------------ ----------                                                           
Ms Wyyyyyyyyy W Wyyyyyyyyy         100000                                                           
Elapsed: 00:00:00.10

Creating the test table

drop table pers;
create table pers
(pers_id             number(8)    not null
,surname             varchar2(30) not null
,first_forename      varchar2(30) not null
,second_forename     varchar2(30)
,pers_title          varchar2(10)
,sex_ind             char(1)      not null
,dob                 date
,addr_id             number(8)
,pers_comment        varchar2(2000)
)
/
insert into pers
select rownum 
      ,rpad(chr(65+mod(rownum,24)),10,chr(65+mod(rownum,25))) 
      ,rpad(chr(65+mod(rownum,24)),10,chr(65+mod(rownum,25))) @cre
      ,rpad(chr(65+mod(rownum,24)),10,chr(65+mod(rownum,25))) 
      ,decode(mod(rownum,4),0,'MR',1,'MRS',2,'Ms',3,'MR','DR')
      ,decode(mod(rownum,2),0,'M',1,'F')
      ,sysdate - (3000+mod(rownum,30000))
      ,rownum +1001
      ,rpad(chr(65+mod(rownum,24)),200,chr(65+mod(rownum,25))) 
from dual
connect by level < 100001
/

Creating the functions and a small package

--num_num
CREATE OR REPLACE FUNCTION normal_num_num(p_id IN NUMBER) RETURN NUMBER IS
v_num number;
BEGIN
  v_num:=p_id*p_id;
  RETURN v_num;
END;
/
CREATE OR REPLACE FUNCTION udf_num_num(p_id IN NUMBER) RETURN NUMBER IS
PRAGMA UDF;
v_num number;
BEGIN
  v_num:=p_id*p_id;
  RETURN v_num;
END;
/
--
-- vc_vc
CREATE OR REPLACE FUNCTION normal_vc_vc(p_id IN varchar2) RETURN varchar2 IS
v_vc varchar2(100);
BEGIN
  v_vc:=substr(p_id,1,5);
  RETURN v_vc;
END;
/
CREATE OR REPLACE FUNCTION udf_vc_vc(p_id IN varchar2) RETURN varchar2 IS
PRAGMA UDF;
v_vc varchar2(100);
BEGIN
  v_vc:=substr(p_id,1,5);
  RETURN v_vc;
END;
/
-- vc_vc_2
CREATE OR REPLACE FUNCTION normal_vc_vc_2(p_id1 IN varchar2,p_id2 IN varchar2) RETURN varchar2 IS
v_vc varchar2(100);
BEGIN
  v_vc:=substr(p_id1,1,5)||substr(p_id2,2,5);
  RETURN v_vc;
END;
/
CREATE OR REPLACE FUNCTION udf_vc_vc_2(p_id1 IN varchar2,p_id2 IN varchar2) RETURN varchar2 IS
PRAGMA UDF;
v_vc varchar2(100);
BEGIN
  v_vc:=substr(p_id1,1,5)||substr(p_id2,2,5);
  RETURN v_vc;
END;
/
--
-- dt_dt
CREATE OR REPLACE FUNCTION normal_dt_dt(p_id IN date) RETURN date IS
v_dt date;
BEGIN
  v_dt:=p_id+1000;
  RETURN v_dt;
END;
/
CREATE OR REPLACE FUNCTION udf_dt_dt(p_id IN date) RETURN date IS
PRAGMA UDF;
v_dt date;
BEGIN
  v_dt:=p_id-1000;
  RETURN v_dt;
END;
/
-- dt_num
CREATE OR REPLACE FUNCTION normal_dt_num(p_id IN date) RETURN number IS
v_num number;
BEGIN
  v_num:=to_char(p_id,'J')+100;
  RETURN v_num;
END;
/
CREATE OR REPLACE FUNCTION udf_dt_num(p_id IN date) RETURN number IS
PRAGMA UDF;
v_num number;
BEGIN
  v_num:=to_char(p_id,'J')-100;
  RETURN v_num;
END;
/
-- num_dt
CREATE OR REPLACE FUNCTION normal_num_dt(p_id IN number) RETURN DATE IS
v_dt date;
BEGIN
  v_dt:=sysdate+(p_id/100);
  RETURN v_dt;
END;
/
CREATE OR REPLACE FUNCTION udf_num_dt(p_id IN number) RETURN DATE IS
PRAGMA UDF;
v_dt date;
BEGIN
  v_dt:=sysdate-(p_id/100);
  RETURN v_dt;
END;
/
create or replace function normal_disp_name (p_sn      in varchar2
                       ,p_fn1     in varchar2
                       ,p_fn2     in varchar2  
                       ,p_title   in varchar2  ) return varchar2 is
v_return     varchar2(1000);
begin
  v_return := case when p_title is null then ''
                   else initcap(p_title)||' '
              end
            ||initcap(p_fn1)||' '
            ||case when p_fn2 is null then ''
                   else substr(p_fn2,1,1)||' '
              end
            ||initcap(p_sn);
return v_return;
end;
/
create or replace function udf_disp_name (p_sn      in varchar2
                       ,p_fn1     in varchar2
                       ,p_fn2     in varchar2  
                       ,p_title   in varchar2  ) return varchar2 is
PRAGMA UDF;
v_return     varchar2(1000);
begin
  v_return := case when p_title is null then ''
                   else initcap(p_title)||' '
              end
            ||initcap(p_fn1)||' '
            ||case when p_fn2 is null then ''
                   else substr(p_fn2,1,1)||' '
              end
            ||initcap(p_sn);
return v_return;
end;
/
create or replace function normal_disp_name_defaults (p_sn      in varchar2
                       ,p_fn1     in varchar2
                       ,p_fn2     in varchar2  
                       ,p_title   in varchar2 :=null  ) return varchar2 is
v_return     varchar2(1000);
begin
  v_return := case when p_title is null then ''
                   else initcap(p_title)||' '
              end
            ||initcap(p_fn1)||' '
            ||case when p_fn2 is null then ''
                   else substr(p_fn2,1,1)||' '
              end
            ||initcap(p_sn);
return v_return;
end;
/
create or replace function udf_disp_name_defaults (p_sn      in varchar2
                       ,p_fn1     in varchar2
                       ,p_fn2     in varchar2  
                       ,p_title   in varchar2 :=null ) return varchar2 is
PRAGMA UDF;
v_return     varchar2(1000);
begin
  v_return := case when p_title is null then ''
                   else initcap(p_title)||' '
              end
            ||initcap(p_fn1)||' '
            ||case when p_fn2 is null then ''
                   else substr(p_fn2,1,1)||' '
              end
            ||initcap(p_sn);
return v_return;
end;
/
create or replace package t_pkg as
function udf_disp_name (p_sn      in varchar2
                       ,p_fn1     in varchar2
                       ,p_fn2     in varchar2  
                       ,p_title   in varchar2 ) return varchar2;
end t_pkg;
/
create or replace package body t_pkg as
function udf_disp_name (p_sn      in varchar2
                       ,p_fn1     in varchar2
                       ,p_fn2     in varchar2  
                       ,p_title   in varchar2 ) return varchar2 is
PRAGMA UDF;
v_return     varchar2(1000);
begin
  v_return := case when p_title is null then ''
                   else initcap(p_title)||' '
              end
            ||initcap(p_fn1)||' '
            ||case when p_fn2 is null then ''
                   else substr(p_fn2,1,1)||' '
              end
            ||initcap(p_sn);
return v_return;
end;
end t_pkg;
/

The test script

-- udf_tests
set lines 100 pages 50
set feed off
col text_output     form a30
col number_output   form 99999999999
col date_output     form a20
spool udf_tests.lst
prompt  running udf_tests
prompt
set pause off
set autotrace off
set timi on
prompt investigating why pragam udf helps some simple functions and not others
prompt ----------------------------------------------------------------------- 
--
prompt
--
prompt simple number in-number out function
select /* mdw_16a */       max(normal_num_num(pers_id)) number_output
       ,count(*) from pers
/
select /* mdw_16b */        max(udf_num_num(pers_id)) number_output
       ,count(*)  from pers
/
prompt
prompt ** udf helps
prompt
--
prompt simple varchar in-varchar out function
select /* mdw_16c */       max(normal_vc_vc(surname)) text_output
       ,count(*) from pers
/
select /* mdw_16d */       max(udf_vc_vc(surname)) text_output
       ,count(*)  from pers
/
prompt
prompt ** udf helps
prompt
--
--
prompt  two varchar in-varchar out function, is the issue with more than one in parameter?
select /* mdw_16e */       max(normal_vc_vc_2(surname,first_forename)) text_output
       ,count(*) from pers
/
select /* mdw_16f */       max(udf_vc_vc_2(surname,first_forename)) text_output
       ,count(*)  from pers
/
prompt
prompt ** udf helps
prompt
--
prompt simple date in-date out function
select /* mdw_16g */       max(normal_dt_dt(DOB)) date_output
       ,count(*) from pers
/
select /* mdw_16h */       max(udf_dt_dt(DOB)) date_output
       ,count(*)  from pers
/
prompt ***************************************************************SIMILAR TIME!!!
prompt udf does not help
prompt

--
prompt is date out the issue,  date in-num out function
select /* mdw_16i */       max(normal_dt_num(DOB)) number_output
       ,count(*) from pers
/
select /* mdw_16j */       max(udf_dt_num(DOB)) number_output
       ,count(*)  from pers
/
prompt ***************************************************************SIMILAR TIME!!!
prompt udf does not help

--
prompt is date in the issue,  num in-date out function
select /* mdw_16k */       max(normal_num_dt(pers_id)) date_output
       ,count(*) from pers
/
select /* mdw_16l */       max(udf_num_dt(pers_id)) date_output
       ,count(*)  from pers
/
prompt ***************************************************************SIMILAR TIME!!!
prompt udf does not help
--
--
prompt
prompt so back to my original function I had issues with
prompt a difference with the multiple vcs in func and my orig func is my orig had defaults
prompt thus I will try a version with no defaults
prompt 
select /* mdw_16m */
        max(normal_disp_name(surname,first_forename,second_forename,pers_title)) text_output
       ,count(*) from pers
/
select /* mdw_16n */
        max(udf_disp_name(surname,first_forename,second_forename,pers_title)) text_output
       ,count(*)  from pers
/
prompt ****************************************************************UDF has an IMPACT
prompt
prompt
prompt now with one of the parameters set to a default 
select /* mdw_16o */
        max(normal_disp_name_defaults(surname,first_forename,second_forename,pers_title)) text_output
       ,count(*) from pers
/
select /* mdw_16p */
        max(udf_disp_name_defaults(surname,first_forename,second_forename,pers_title)) text_output
       ,count(*)  from pers
/
prompt ****************************************************************UDF has NO IMPACT
prompt ****************************************************************ALSO defaults cause both versions to be slower
prompt 
prompt now call the simple disp_name_udf function that benefits standalone from within a package
prompt
prompt standalone
select /* mdw_16q */
        max(udf_disp_name(surname,first_forename,second_forename,pers_title)) text_output
       ,count(*)  from pers
/
prompt
prompt within package
select /* mdw_16r */
        max(t_pkg.udf_disp_name(surname,first_forename,second_forename,pers_title)) text_output
       ,count(*)  from pers
/
prompt *********************************************** WORKS - so long as neither spec of body have prm defaults
prompt
prompt and just to round of, using a subquery factored function which my prior tests showed reduced overhead
with 
  function l_disp_name(p_sn      in varchar2
                      ,p_fn1     in varchar2
                      ,p_fn2     in varchar2  
                      ,p_title   in varchar2 )
return varchar2
is
v_return     varchar2(1000);
begin
  v_return := case when p_title is null then ''
                   else initcap(p_title)||' '
              end
            ||initcap(p_fn1)||' '
            ||case when p_fn2 is null then ''
                   else substr(p_fn2,1,1)||' '
              end
            ||initcap(p_sn);
return v_return;
end l_disp_name;
select /*mdw_16s */
        max(l_disp_name(p_sn =>surname           ,p_fn1  =>first_forename
                       ,p_fn2=>second_forename   ,p_title=>pers_title)        ) text_output
       ,count(*)
from pers
/

prompt the WITH function benefits even with defaults
with 
  function l_disp_name(p_sn      in varchar2
                      ,p_fn1     in varchar2
                      ,p_fn2     in varchar2 :=null  
                      ,p_title   in varchar2 :=null )
return varchar2
is
v_return     varchar2(1000);
begin
  v_return := case when p_title is null then ''
                   else initcap(p_title)||' '
              end
            ||initcap(p_fn1)||' '
            ||case when p_fn2 is null then ''
                   else substr(p_fn2,1,1)||' '
              end
            ||initcap(p_sn);
return v_return;
end l_disp_name;
select /*mdw_16t */
        max(l_disp_name(p_sn =>surname           ,p_fn1  =>first_forename
                       ,p_fn2=>second_forename   ,p_title=>pers_title)        ) text_output
       ,count(*)
from pers
/
--
spool off

Friday Philosophy – We Could Be Heroes! {just for one day}. November 6, 2015

Posted by mwidlake in Friday Philosophy, humour, Perceptions.
Tags: , , ,
3 comments

At Open World I overheard a snippet of conversation which went something like this:

Bob – “How’s it going? Did the last talk go down well?”
Bill – “Sure, it was on time, the audience seemed to like it.”
Bob – “Will you be here next year?”
Bill – “Errmm….” pause…*sigh*… “I don’t know…. I’ll see how I feel.”
Bob – “Oh? In what way?”
Bill – “It just that, at Open World… I have to fend off two dozen people just to go have a pee!”

Wild horses could not drag out of me the name of the person who said that (though several pints and the offer of a curry might do the trick – try me). It both made me smile and made me think. There are down-sides to becoming highly respected in your sphere.

There are definitely different levels of renown and respect in the relatively small world of the Oracle Database Technologist. I’m not doing bad in that respect; I’d put myself in the third of the seven circles, maybe tapping on gates of circle two. Occasionally I think it would be nice to be either technically or entertainingly good enough to join the Big Names in the innermost circle – but I really don’t think I can face the Hem-Touching!

What do I mean about “Hem-Touching”? It’s something a few friends and I came up with at the UKOUG Tech conference about 5 or 6 years ago to describe people who will approach one of the Oracle Names with a mixture of awe and fear in their eyes and just want them to acknowledge their presence,be allowed to speak, maybe to touch the hem of their cloak. If you go up to the balcony that is above the exhibition hall at the Birmingham ICC, you can sometimes watch an Oracle Name walk through the exhibition and see some people suddenly swerve and hurry towards them – especially if the Name currently has no one with them. I’ve even seen someone suddenly stop when another acolyte gets to their hero first. I don’t know why, these people will speak to more than one person at a time. And the thing is, people in the UK and Europe are generally more reserved than our cousins in other continents, so we are less forward in, well, being forward.

Am I being mean to these people? Well, a little I guess, but it’s mainly because of the little story I started with. I’m friends with some of the Names and I know a lot of them are uncomfortable with Hero Worship. Being respected and held in high regard is great, most of them are very happy about that, as they have worked damned hard and long to be knowledgeable enough to hold that position. But when people treat them like a living saint or the bestower of blessings, it’s just a bit weird. This is just an area of technology after all, not the eradication of Malaria. They are “just” people – OK, they are people who are usually very smart and very capable, but they are also people who are happy to share and teach – otherwise they would not be at the conferences sharing and teaching. Most of them are idiots in other areas of their lives too, we all are.

I’ve never felt the need to hero-worship myself. Not because I do not deeply respect people who achieve great things, it’s just not in my psychology I think. I did not put up any posters in my bedroom of the people I most respected when I was a teenager. I used to know a Nobel Prize Winner (though I doubt he’d recognise me in the street now) but when I met him the first time I had no idea who he was and just treated him like a person – and we got on fine. He treated me like a person too. I’ve been lucky enough to meet some very smart academics, many of the Oracle Names and even the odd traditionally famous person. It’s amazing how like people they are – if you treat them like people.

I’m certainly not above being pleased when someone I respect mentions me or refers to something I have done though. I’ll grin like an idiot on the rare occasions someone has name-checked me in a presentation or they tell me they liked something I said. I’m tickled pink when a Name follows me on twitter. But I feel hero worship is not what they want. Respect yes, being told you appreciate what they have taught you fine. Going shiny-eyed and asking to touch the hem of their coat, weird; don’t do it.

Oracle Names are people, treat them as such. They’ll probably appreciate you more if you do.

And if you ever find yourself in a group of several others, all trying to say “hello” to some gal or guy you just saw presenting, and they are looking a little uncomfortable and shifting from foot to foot and looking towards a door over there – let the poor sod go to the loo will you?

Pragma UDF – Speeding Up your PL/SQL Functions Called From SQL November 4, 2015

Posted by mwidlake in performance, PL/SQL, SQL.
Tags: , , ,
7 comments

A new feature for PL/SQL was introduced in V12, pragma UDF. UDF stands for User Defined Functions. It can speed up any SQL you have that uses PL/SQL functions you created yourself.

{please see this second post on some limitations of pragma UDF in respect of IN & RETURN data types and parameter defaults}.

We can create our own functions in PL/SQL and they can be called from both PL/SQL and SQL. This has been possible since V7.3 and is used extensively by some sites to extend the capabilities of the database and encapsulate business logic.

A problem with this, though, is that every time you swap from SQL to PL/SQL (or the other way around) you have to do a context switch each time, which can be quite cpu and memory intensive. If you are using your own PL/SQL function in the SELECT list of a SQL statement and you are selecting a lot of rows (say as part of a business report) then the overhead can be quite considerable as you could be doing a context switch per row. I won’t go into too much detail here (partly as I go in to considerable detail on the subject in a book I am working on for 2016) on how you can investigate the context switching and when exactly it occurs, but I will show you one of the two new ways in Oracle 12 to reduce the overhead, namely PRAGMA UDF. At present this seems to be a little used and rarely-mentioned feature on the blogsphere, with articles just covering simple examples of almost no-business-function, numeric functions.

I’ll give you a slightly less simple example but my next post will give you details on some limitations of pragma UDF. Here I am just setting the scene. I have the below PERSON table which has the parts of the names in distinct columns, with the contents forced to upper case (as is standard practice). We will create a function to provide a nicely init-capped and spaced display name and a second function which is identical but uses PRAGMA UDF.

PERSON
Name                                     Null?    Type
---------------------------------------- -------- ---------------
PERS_ID                                  NOT NULL NUMBER(8)
SURNAME                                  NOT NULL VARCHAR2(30)
FIRST_FORENAME                           NOT NULL VARCHAR2(30)
SECOND_FORENAME                                   VARCHAR2(30)
PERS_TITLE                                        VARCHAR2(10)
SEX_IND                                  NOT NULL CHAR(1)
DOB                                               DATE
ADDR_ID                                           NUMBER(8)
STAFF_IND                                         CHAR(1)
LAST_CONTACT_ID                                   NUMBER(8)
PERS_COMMENT                                      VARCHAR2(2000)


create or replace function normal_disp_name (p_sn      in varchar2
                                            ,p_fn1     in varchar2
                                            ,p_fn2     in varchar2  
                                            ,p_title   in varchar2  ) return varchar2 is
v_return     varchar2(1000);
begin
  v_return := case when p_title is null then ''
                   else initcap(p_title)||' '
              end
            ||initcap(p_fn1)||' '
            ||case when p_fn2 is null then ''
                   else substr(p_fn2,1,1)||' '
              end
            ||initcap(p_sn);
return v_return;
end;
/
create or replace function udf_disp_name (p_sn      in varchar2
                                         ,p_fn1     in varchar2
                                         ,p_fn2     in varchar2  
                                         ,p_title   in varchar2  ) return varchar2 is
-- The Below is the KEY bit
PRAGMA UDF;
v_return     varchar2(1000);
-- {Identical from here}

-- select some data with one of the functions, it does not matter which
select pers_title title,    first_forename    ,second_forename    , surname
      ,normal_disp_name(p_sn =>surname           ,p_fn1  =>first_forename
                       ,p_fn2=>second_forename   ,p_title=>pers_title) display_name
from person
...


TITLE   first_fn   secon_fn   SURNAME         DISPLAY_NAME
------- ---------- ---------- --------------- ----------------------------
MR      HARRISON   RICHARD    HARRIS          Mr Harrison R Harris
MRS     ANNEKA     RACHAEL    HARRIS          Mrs Anneka R Harris
MRS     NICKIE     ALISON     ELWIG           Mrs Nickie A Elwig
MASTER  JAMES      DENZIL     ELWIG           Master James D Elwig
MR      JEFF                  GARCIA          Mr Jeff Garcia
...
MRS     AMELIA     MARIA      ORPINGTON-SMYTH Mrs Amelia M Orpington-Smyth

So we have our test table, you can see my normal_disp_name function and that the *only* difference with the second version is the inclusion of PRAGMA_UDF in the declaration section. That is partly why it is such a nice feature, you can just add this one line to existing code and you should get the benefit. Should….. {see second post when I do it}

Finally, I show some code using the function and the output.

To demonstrate the impact of context switching I will select 100,000 records from my test table in 3 ways: using only native SQL functions and thus no context switching; using my traditional PL/SQL function which suffers from context switching; with my new “pragma UDF” function to reduce the overhead of the context switching.

select avg(length(
      case when pers_title is null then ''
                   else initcap(pers_title)||' '
              end
            ||initcap(first_forename)||' '
            ||case when second_forename is null then ''
                   else substr(second_forename,1,1)||' '
              end
            ||initcap(surname)
          )      )  avg_name_length
       ,count(*)
from person
where pers_id > 100100
and rownum < 100000

select  avg(length(normal_disp_name(p_sn =>surname           ,p_fn1  =>first_forename
                                   ,p_fn2=>second_forename   ,p_title=>pers_title)        ) ) disp_name_len
       ,avg(addr_id)
       ,count(*)
from person
where pers_id > 100100 and rownum < 100000

select  avg(length(udf_disp_name(p_sn =>surname           ,p_fn1  =>first_forename
                                ,p_fn2=>second_forename   ,p_title=>pers_title)        ) ) disp_name_len
       ,avg(addr_id)
       ,count(*)
from person
where pers_id > 100100 and rownum < 100000

One thing to mention in passing is that the code using either function is much easier to read and self-documenting. This is one of the benefits of proceduralising your code, as well as creating just one place to maintain it. If I had to re-use that native-SQL section in a half-dozen reports I would probably mess up at least one of the times I cut-and-paste it and I would now have several places to maintain that code.

I ran the test statements several times and took the average of the 2nd to 6th runs, to remove the initial parsing & caching overhead that comes with the first execution and to get more reliable figures than one further run would give me.

Version                      Run Time average (secs)
Native SQL                   0.03
Traditional PL/SQL           0.33
PRAGMA UDF PL/SQL            0.08

As you can see, just including PRAGMA UDF removed most of the overhead caused by context switching.

How does PRAGMA UDF work? I’m not sure, the official Oracle documentation is pretty light on it and just says:

“The UDF pragma tells the compiler that the PL/SQL unit is a user defined function that is used primarily in SQL statements, which might improve its performance

Note the italics (which are mine). “Might improve its performance” but no detail as to what it does. As I understand it, it alters the internal representation of data as it is passed between the SQL and PL/SQL engines via the IN and RETURN values (Note it does not change the data types!) – but treat that as a bit of wild speculation for now. I have some evidence for it that you will see in, yes, the next post.

Pragma UDF can slow down slightly functions being called directly from PL/SQL. So use it only for functions you know will be called from SQL.

I’ll make one other observation. Using PL/SQL functions increased the run time to process 100,000 records on my modest test system by all of 0.3 seconds. But that is 10 times the time taken for the native SQL statement. Pragma UDF removes around 80% of this overhead. It’s a nice saving but is probably inconsequential if your code is actually doing any physical IO at all (my example is processing already cached blocks). And if you are only processing a few records or one record in a GUI screen, the context switching is moot {meaning, of no significance}.

But if you have code that processes a huge set of data and uses a lot of user defined PL/SQL functions (and again I go into a lot more detail about this in the book) using pragma UDF in 12C could gain you quite a bit of extra performance. If you have code where even 0.00001 seconds is important (think trading systems) then again there may be a worthwhile benefit.

OOW Report – No List of Talks, No Cloud, Just Thoughts on Community October 30, 2015

Posted by mwidlake in conference, Perceptions, User Groups.
Tags: , ,
4 comments

As I type I am in my hotel, sipping a final beer (it was a gift that has been to a few talks with me in my backpack) and looking back at Oracle Open World 2015. I must confess I am a little drunk so we will see if this post lasts…
{Update – it passed the next-morning-sobriety test. I was only a little drunk}

OOW15 beers

I am on record as saying I don’t like Open World. I came to previous events in 2003 and 2004 I think (yes, over a decade back), both times at short notice on the behest of the Mother Corporation. And at those times I only knew people at the event from Corporation Oracle – not people in the Oracle User Community. It is miserable being 1 of xx thousand people who you *should* share interests with but simply don’t know. Oracle employees are generally excluded from the event so that removed nearly all of my contacts. It is such a large event that if you meet someone on Sunday and chatted to them – you may well never see them again! After all, it is 1 in x thousand people even for your specific area of interest. I’m not good at chatting to people “cold” and the whole “entering the US” is such a bloody awful experience (Immigration just shout at you and growl and are, frankly, as welcoming as a Rottweiler at a kitten party) that the total experience from beginning to end was just, well, less pleasant than a bad week in the office.

This time was very, very different (though not the growling Rottweiler bit, sadly). Because I am now an active member of a couple of oracle “clubs” (Oracle ACE and OakTable) I knew more people. Because I blog and tweet I knew a lot of USA {and other} people, if only via social media. As a result of going to a good few different user groups (and often presenting) I have become friends with people from several communities. And I have also got better at “Cold chatting”. So for several days I have been meeting people like Danny Bryant (still my hero as he got my conference pass back to me after I dropped it on a bus!), Bobby Curtis, That Jeff Smith, Sarah CraynonZumbrum, Zahid Anwar… and about 37 other people I had never met or only met once. I have re-connected with a couple of dozen old friends too and hung around with closer friends from the UK & Europe. And it has been great. This is one of the great aspects of being an active member of the Oracle Community, there is a pool of people I can now talk to and relax with.

I’ve loved my OOW15 experience and that is fundamentally because I felt I was inside rather than outside. At this point I was planning to say that not everyone you meet in the flesh will turn out to be people you actually get on with – but I can honestly say that everyone I have met this week has been at least polite to me, most have been welcoming. I’m not saying all will be life-long friends and I am at long last wise enough to recognise that someone being polite to me does not mean they did not find me annoying. But one of the great things about a user group community is that almost everyone in it is actually on the “friendly” side of normal. If you are not, user groups are not going to be your thing!

It makes a huge difference. Being able to find someone (and modern social media makes that so much easier than a decade back when I hated this experience) to have a coffee with and a nice conversation can make a potentially lonely gap between presentations into an enjoyable afternoon. I missed half a dozen presentations this week as the conversations went on much longer and were more illuminating than you planned. I could just position myself at a central location and pretty soon a friend would wander by. Or, at least, someone who would not run away🙂

Being mindful of the above, if anyone came up to me to talk, I talked to them. There is a phrase that seems current in the US of “paying it forward” which means if you have had a nice experience, try to make someone else’s experience nice. Or is it “paying it backward”? I don’t know for sure but I like both. If you have been helped, help someone. If you think people should help each other, start it by being helpful first. I was able to do this a little bit myself by making sure I was around if a friend called Stew needed some company, as he is not as tied into the user community as others as he is new to this. However, I don’t think this will last as he is making such a name for himself that next year he’ll be introducing me to people! In turn, another friend, Brendan, made time to make sure I had company as he knew I’d not liked my prior experiences.

So all in all I now don’t dislike OOW. I like OOW. And the reason is the user community is there for me. It’s there for everyone who wishes to be a part of it. You won’t like everyone, everyone won’t like you – but that is fine, we all have our different characters – but you will gel with a good few people.

Note I have not mentioned presentation slots. Some were good, some were bad, a small number were great and a similar number were awful. But I did learn a lot and I appreciate the fact. I will say no more as, frankly, if you were not at the conference then a discussion of the presentations is pretty pointless!

I just want to end on a final consideration. I know I am now a member of a couple of “clubs” and that helps me in knowing people. But a lot of people I now know are not members of either of those clubs and I know them due to my simply being social-media active, a user group attender and I make myself cold-chat more. It almost hurts me to say it, but social media can be a good thing. Nothing beats face-to-face socialising, but knowing people virtually first is a great help in getting started with meeting them for real.

I really love the user group community. Or is that just the beer talking (which I finished over an hour back!)

{update – OK, it was the beer, I don’t love any of you. But I like you a lot…}
 

The “as a Service” paradigm. October 27, 2015

Posted by mwidlake in Architecture, Hardware, humour.
Tags: , , ,
4 comments

For the last few days I have been at Oracle Open World 2015 (OOW15) learning about the future plans and directions for Oracle. I’ve come to a striking realisation, which I will reveal at the end.

The message being pressed forward very hard is that of compute services being provided “As A Service”. This now takes three flavours:

  1. Being provided by a 3rd party’s hardware via the internet, ie in The Cloud.
  2. Having your own hardware controlled and maintained by you but providing services with the same tools and quick-provisioning ideology as “cloud”. This is being called On Premise (or just “On Prem” if you are aiming to annoy the audience), irrespective of the probably inaccuracy of that label (think hosting & dedicated compute away from head office)
  3. A mix of the two where you have some of your system in-house and some of it floating in the Cloud. This is called Hybrid Cloud.

There are many types of  “as a Service offerings, the main ones probably being

  • SaaS -Software as a Service
  • PaaS – Platform as a Service
  • DBaas – Database as a a Service
  • Iass – Infrastructure as a Service.

Whilst there is no denying that there is a shift of some computer systems being provided by any of these, or one of the other {X}aaS offerings, it seems to me that what we are really moving towards is providing the hardware, software, network and monitoring required for an IT system. It is the whole architecture that has to be considered and provided and we can think of it as Architecture as a Service or AaaS. This quick provisioning of the architecture is a main win with Cloud, be it externally provided or your own internal systems.

We all know that whilst the provision time is important, it is really the management of the infrastructure that is vital to keeping a service running, avoiding outages and allowing for upgrades. We need a Managed Infrastructure (what I term MI) to ensure the service provided is as good as or better than what we currently have. I see this as a much more important aspect of Cloud.

Finally, it seems to me that the aspects that need to be considered are more than initially spring to mind. Technically the solutions are potentially complex, especially with hybrid cloud, but also there are complications of a legal, security, regulatory and contractual aspect. If I have learnt anything over the last 2+ decades in IT it is that complexity of the system is a real threat. We need to keep things simple where possible – the old adage of Keep It Simple, Stupid is extremely relevant.

I think we can sum up the whole situation by combining these three elements of architecture, managed infrastructure and simplicity into one encompassing concept, which is:

KISS MI AaaS.

.

.

And yes, that was a very long blog post for a pretty weak joke. 5 days of technical presentations and non-technical socialising does strange things to your brain