Thursday, December 29, 2005

TMI: The Half-Life of Oranges

Recently, I've developed a habit of walking to a nearby grocery store every Sunday afternoon and buying three oranges and a bunch of bananas [along with some junk food to keep my diet "balanced"].

My intention is to eat an orange on Monday, Wednesday, and Saturday nights. Monday night all 3 oranges seem equally firm, so I pick one at random, and it tastes great. But by Wednesday night, one of the oranges has turned moldy and squishy and I'm forced to toss it out and eat the surviving orange which tastes just fine.

Now I could go to the store on Saturday night and make up for the lost orange (and I probably should burn the extra calories), but then I'd feel obligated to buy more stuff rather than stand in line with a single orange. So I have two of the bananas instead. Fortunately, the bananas seem to ripen much more predictably.

Guess I need some education on choosing oranges, or this Sunday, I'll buy 4 just to see what happens...

Wednesday, December 21, 2005

Sunday, December 18, 2005

TMI: Follow the Leader

Guess I decided to join the trend and widen the columns of my blog. The toughest part was figuring out how to keep the rounded corners. Tried looking for free GIF editors, and the ones I stumbled across looked to complicated for what little I was trying to do. Finally discovered CSS3 will eventually take care of it for me, but until then, I'll have to settle for the Mozilla specific -moz-border-radius parameter. The columns still come out boxy in IE (and IE doesn't fill in the background for my random quote of the day), but I figure it's a good thing to have a web page render nicely in Firefox than IE anyway.

People had pointed me to blogs a couple of years ago, and I actually started one last year. Then work immediately piled up, and I forgot where it was .. until today. Strange that it even has the same title and everything. I like the interface on Blogger better though I do wish it had the calendar and a way to categorize postings. Alternative would be to start multiple blogs but that might be a hassle. Plus apparently I'm only good at coming up with one title.

Movies: Random Short Reviews

The UK newspapers have been reporting on the first actual face transplant in France. It made me wonder how much longer before life imitates the art of Face/Off. I found it far-fetched that you could fool someone's closest friends and family by just switching faces (and swallowing a voice modulator). Eventually the change in accent or body language might give one away. Or you wonder if the spouse would notice other anatomical or body language differences of a different sort. But the ruse just had to be good enough to fool the strangers in the movie-going audience and John Travolta and Nicholas Cage did that pretty well. Add some great action direction from John Woo and the minimum number of summer chases and explosions and you have a fun movie. Grade B-

As a subscriber to the full cable package, I get to watch movies that I didn't feel he were worth even paying matinee prices. One of those was another Nicolas Cage thriller titled National Treasure. It was fun to look at, yet plodding. The only saving graces were Justin Bartha as Riley whose injections of humor were too few and far between and the scene where Ben has to buy the document he just stole -- though I don't recall the actual lobby and the store at the National Archives being as large. Ultimately, the efforts resulted in an overpriced and lame attempt to capitalize on the popularity of The DaVinci Code (replace famous Renaissance Man with American Founding Fathers) while failing to recapture the charm and fun of Raiders of the Lost Ark. It is sort of a tossup as to whether this movie was better than another Indiana Jones ripoff called King Solomon's Mines. National Treasure wins in effects and explosions with a newer technology and a bigger budget, but as lovely as Nick Cage and especially Diane Kruger are to look at, they would lose in a Celebrity Deathmatch - beauty contest to the Richard Chamberlain / Sharon Stone tag team. But that may not stop me from watching the recently announced sequel -- on cable. Grade C+

It was probably more than a rumor that Nick Cage was going to play Superman (I think I even remember seeing a cutout of him in the famous blue costume at a movie theater. He even named his son Kal-el. But more about Superman in a minute. First we talk about the other big hero from DC Comics, Batman. Director Christopher Nolan, who directed the instant classic movie, Memento, and a better than decent American adaptation of Insomnia, saved the whole Batman franchise with Batman Begins. Nolan has injected his signature way of portraying psychological themes (the main one being fear) that has been sorely missing in recent Batman movies, making it the best of modern Batman movies (Batman loses points for casting Prince in a musical cameo, and letting Jack Nicholson as the Joker outshine the hero) and perhaps the best of all Batman movies. The only weak points were letting Liam Neeson remind me too much of his Qui-Gon Jinn character (though it may have been the only decent acting job in the otherwise awful Phantom Menace), and failing to make us fully believe that Katie Holmes could be a tough DA assistant. It will be a challenge to see if an even better sequel can be conceived. I'd instead nominate Nolan to take a crack at the graphic novel classic Watchmen. For now it places just misses beating out 1978's Superman and lands in a close race with the recent Spider-Man 1 and 2, X-Men, and X2 as best movie adapted from a comic book series. Grade A-

So getting back to Superman, WB revealed the trailer for Superman Returns before Harry Potter and the Goblet of Fire. The sneak peak looked pretty cool, but it gave me the impression that they were just remaking the 1978 version, and maybe introducing come continuity issues with the TV series Smallville (though I've only seen a few episodes). You have to dig around the Internet a bit to find out it will not be the case. Director Bryan Singer has not disappointed me yet with The Usual Suspects, aforementioned X-Men films, and "House, MD", so I hope that his track record continues (even after Superman with Logan's Run).

As for the Goblet of Fire itself, I enjoyed it. It didn't seem as fun and imaginative as The Prisoner of Azkaban, but does achieve the goal of portraying the awkwardness of the transition from childhood to adulthood. Or at least I presume that is what is meant by the tagline "Everything Will Change." Some scenes brought back painful but funny memories of trying to find a date to the Junior Prom. Some of my friends who watched the movie walked away totally disappointed. They believed too much was cut from the book. This is why I've decided not read popular books until after movies are made (if ever). It's rare to find movies that improve over the book much less meet the 'fanboy' expectations. Finally, there is a general consensus of disappointment with the actor playing Dumbledore. But who could possibly fill the robes of a legend like Richard Harris. Grade B

Thursday, December 15, 2005

ORCL: Mysterious Performance Drop

This is based on true stories that I've run into about 3 times over the last few years (though coincidentally two of these cases appeared in the same week):

A customer's environment kept slowing down every afternoon for a few weeks in a row. Most of the time the slowdown would only last 10 or 20 minutes and then return to normal. However on certain days, performance would degrade and keep decaying until they were forced to shutdown and restart the database. Then the problem would go away until the next day. The claim was that nothing has changed recently to trigger this behavior.

So it was time to glance at some Statspack reports. During acceptable periods, top Timed Events were CPU time and some IO related events. First statspack when the problem starts shows "latch free" jumping to the lead. If the problem corrects itself, CPU returns to the top and everything pretty much looks like the BEFORE problem report again. But on the days where the problem did not correct itself, IO events jumped to the top followed by "latch free" and "buffer busy waits". Interesting.

Jumping to the latch stats section the first symptom was consistently high library cache latch. Then those waits would disappear and on the really bad days "cache buffers chains" jumped to the top. Okay, first symptom is usually a sign that there's some churn in the shared pool with old SQL getting aged out and new ones coming. And when IO becomes a problem (with high buffer cache activity, etc.), it implies some new IO heavy SQL got introduced.

However, the customer says the application transaction mix should not be changing. Top SQL shows all the same SQL with relatively same ratios of execution (all lower of course). But physical reads and buffer gets for one SQL has increased markedly -- execution plan must have changed! But customer swears that they are not loading massive amounts of data or gathering stats in the middle of some days, plus it seems like the old execution plan comes back after bouncing the database.

So what's the simplest story that would fit the symptoms?

Answering that required knowing or finding out a couple of bits of information about how Oracle works. "Are you guys are creating new user accounts every day at noon now and granting them privileges to the application tables?" Turns out the answer is positive and they had changed from running those scripts overnight to middle of the day. First part of mystery explained. Not many people know that grants on tables will invalidate dependent SQL in the shared pool. Didn't think the change was significant enough to mention.

But what about the second part? Ever heard of bind peeking? CBO will calculate some costs for inequality predicates (or equality predicates against columns with histograms) based on the bind value of the first person who loads the SQL into the shared pool -- or if it is getting reloaded after a grant has invalidated the old version. Customer just had some bad luck the last couple of weeks that the first hard parse may have put in values that were not representative of typical usage.

Final solution, only issue grants during off hours again. To be safe about the bind peeking, they associated an outline of the good plan to the dangerous SQL. Adding a HINT wasn't an option as it was a third party app. Disabling bind peeking could have broken other SQL plans that needed that feature.

Below is a simplified case to illustrate what was happening. Easier to see if it is done from two SQL*Plus sessions sitting side by side:

Session 1:
REM T1: Set up test case
var x number;
var y number;

create table bigtab as select * from all_objects;
create index bt_ix on bigtab (object_id);

execute dbms_stats.gather_table_stats (ownname=>'SCOTT', -
tabname=>'BIGTAB', CASCADE => TRUE, -
method_opt => 'FOR ALL COLUMNS SIZE 1');

REM Start with narrow range of values
begin :x := 1000; :y := 1001; end;
/

SELECT COUNT(*) FROM BIGTAB WHERE OBJECT_ID BETWEEN :x and :y;

REM Goto session 2 - exec plan should be index range scan
REM T3: now lets re-execute with a wide range

begin :x := 0; :y := 50000; end;
/

SELECT COUNT(*) FROM BIGTAB WHERE OBJECT_ID BETWEEN :x and :y;

REM Goto session 2 again - exec plan should still be the same

REM T5: So lets invalidate this puppy

GRANT SELECT ON BIGTAB TO ORDSYS;

REM now query against v$sql_plan and v$sql in session 2 shows
REM "no rows selected"
REM T7: so now lets reload the cursor

SELECT COUNT(*) FROM BIGTAB WHERE OBJECT_ID BETWEEN :x and :y;

REM now session 2 shows a new plan with FAST FULL SCAN and it will
REM be used from now on no matter what the bind values are.

REM T9: so let's turn off bind peeking off

alter session set "_optim_peek_user_binds" = false;

SELECT COUNT(*) FROM BIGTAB WHERE OBJECT_ID BETWEEN :x and :y;

REM now v$sql_area will show version count of 2 (cause some other
REM session may still have bind peeking enabled)


Session 2:
column operation format a20
column options format a20
column object_name format a20

REM T2: After initial load with narrow range binds

select sql_id, sql_text from v$sql where sql_text like
'SELECT COUNT(*) FROM BIGTAB%';

SQL_ID
-------------
SQL_TEXT
-----------------------------------------------------------------
2aa40mj45939v
SELECT COUNT(*) FROM BIGTAB WHERE OBJECT_ID BETWEEN :x AND :y



select operation, options, object_name from v$sql_plan
where sql_id = '2aa40mj45939v';

OPERATION OPTIONS OBJECT_NAME
-------------------- -------------------- --------------------
SELECT STATEMENT
SORT AGGREGATE
FILTER
INDEX RANGE SCAN BT_IX

REM T4: Plan for second SQL still the same
select operation, options, object_name from v$sql_plan
where sql_id = '2aa40mj45939v';

OPERATION OPTIONS OBJECT_NAME
-------------------- -------------------- --------------------
SELECT STATEMENT
SORT AGGREGATE
FILTER
INDEX RANGE SCAN BT_IX

REM T6: after grant is issued

select operation, options, object_name from v$sql_plan
where sql_id = '2aa40mj45939v';

no rows selected

select sql_id from v$sql where sql_id = '2aa40mj45939v';

no rows selected

REM T8: Now cursor is reloaded

select operation, options, object_name from v$sql_plan
where sql_id = '2aa40mj45939v';

OPERATION OPTIONS OBJECT_NAME
-------------------- -------------------- --------------------
SELECT STATEMENT
SORT AGGREGATE
FILTER
INDEX FAST FULL SCAN BT_IX

select loads, invalidations, executions, version_count
from v$sqlarea
where sql_id = '2aa40mj45939v';

LOADS INVALIDATIONS EXECUTIONS VERSION_COUNT
---------- ------------- ---------- -------------
2 1 1 1

REM T10: After session altered "_optim_peek_user_binds" = FALSE
REM and query re-executed.

select loads, invalidations, executions, version_count
from v$sqlarea
where sql_id = '2aa40mj45939v';

LOADS INVALIDATIONS EXECUTIONS VERSION_COUNT
---------- ------------- ---------- -------------
3 1 2 2

select operation, options, object_name from v$sql_plan
where sql_id = '2aa40mj45939v' order by plan_hash_value;

OPERATION OPTIONS OBJECT_NAME
-------------------- -------------------- --------------------
FILTER
SORT AGGREGATE
SELECT STATEMENT
INDEX FAST FULL SCAN BT_IX
FILTER
SORT AGGREGATE
SELECT STATEMENT
INDEX RANGE SCAN BT_IX

Monday, December 12, 2005

TV: Amazing Race - Pedestrian Predictions

I was incorrect about the Amazing Race ending last week. Tuesday Dec 13 is the day of the two-hour finale. From the trailer for the final show it looks like the teams will go to the great northwest, search a stadium, and take at least one flight somewhere which may act as a bunching opportunity.

Ranking the teams
Linzs (I thought it would be Linzes but not in the CBS promos): 2-1
They may be the strongest team, but sometimes they can get cocky, and cocky teams have an odd habit of losing the final leg of the race.

Bransens: 4-1
Nice, boring teams don't win reality shows especially ones that have already won free gas for life and now a new car to fill up. If gas prices go up, and they learn to siphon the gas out and resell it from time to time, the prizes may be worth more than the million-dollar winnings. It looks like Daddy Bransen may fall victim to a needle in the haystack type challenge that brought down the Gaghans (who I had been rooting for). But the editors of the Amazing Race are good at throwing red herrings in their previews.

Weavers: 3-1
They may feel the power of Jesus is on their side while the other teams have treated them like lepers. They could be right(eous) in the end. Plus it makes Phil look like a prophet when he inspired the demoralized Weavers with good tidings of previous teams that had improved from worst to first after a non-elimination round. The Weavers' disadvantages are struggling at detours and occasionally not divining the swiftest path from point A to point B.

Now, I was ready to jot this all down last week, but I got, um...., distracted by the Victoria's Secret Show. The years when the broadcast was on the Internet, I didn't watch because I knew every one else would be. Plus how much detail can you really discern in a low resolution picture the size of a postage stamp. Then when they first appeared on network television, the shows were quite boring. After all, it was just people walking up and down on a catwalk. Even the bathing suit competition in the Miss Universe pageant lasts just one segment. If I remember correctly, the show was on ABC the first year. All I vaguely remember was that Rupert Everett was kind of unconvincingly leering as a host, and then he came out of the closet. When CBS took over the special, I guess they must have brought in the folks who did the Fashionably Loud events on MTV (who remembers House of Style with Cindy Crawford, then Rebecca Romijn?). Now the show almost elicits a seizure with camera switches every few seconds. But I guess that just adds to the distraction factor. Perhaps the theory was to move so fast that nobody would notice any wardrobe malfunctions (except for a shoe coming off). B-

Friday, December 09, 2005

TMI: Too Bogged to Blog

This was a wild week. Had to juggle work (including a 5:30am conference call) with taking care of some personal business. And on the one night I had a few moments of time, there seemed to be router problems between my ISP and blogspot.

One potential downside to renting an apartment is every so often, the landlords can decide to enter for special purposes. But fortunately they give a couple of days notice before that event, and it gives me an excuse to do something important once in a while... clean.

Between landlord visits, my place slowly devolves into something resembing Dr. Cristina Yang's place in Grey's Anatomy. But for those of you that do not watch what I feel is the best network show on TV for 2005 (with Lost a close second), I guess I'd have to describe things in terms of what my place might look like if the landlord never showed up: Some psychologist might mistake my laziness for Obsessive Hoarding Behavior. Some colleagues claim that my office has become sort of a company history museum, but I've been very careful to store very little new for the last few years (documents are all online instead if possible).

So part of last week was spent throwing stuff out, and organizing stuff I want to keep for now. Main side task has been reducing 5 years of magazines down to a more managable and smaller pile of a few months. Just in time for me to trade some miles on an airline I rarely fly for more subscriptions...

Hopefully, I'll get back to blogging over the next few days, even if my opthamologist is recommending I spend less time in front of a computer and more time staring at far away places.

Friday, December 02, 2005

TMI: An Odd Bird

I definitely would not classify myself a bird watcher. Maybe at best I'm a bird noticer who coudn't really name too many species. Anyway about a year ago, a strange-looking bird decided to call my apartment complex its home. At first, I'd be lucky to catch a glimpse of it about once every few weeks. Usually it would be at 2AM, when I'd be dragging myself home after working too late or catching a late movie optionally followed by a very late dinner or very early breakfast at Denny's. [I'd like to say I had been out clubbing instead, but too many people know me too well.] As soon as the bird would see me, it would dart off and disappear into the darkness. I figured I might be a figment of my imagination [particularly the type of imagination that kicks in after 2AM where I think I have a great idea, write it down, read it the next morning, then think to myself, "How did I come up with such a stupid idea?"], so I only mentioned it to a few people (who didn't seem to care). I worried if I told more people, they'd start looking at me the way people looked at Big Bird when he was still the only character who witnessed Mr. Snuffleupagus.

But tonight the bird decided to appear shortly after sunset for everyone to see. One lady who's lived at the same apartment complex as long as me if not longer was outside her apartment smoking a cigarette just 10 ft. from the bird. So I decided to talk to her.

"Do you know what kind of bird that is?" I asked.
"I think it's an Ereu."
"Arrow? How do you spell that?"
"T-H-A-T." [we both laugh] "No I think it's E-R-E-U. Usually I only see that guy hanging out after midnight pecking for bugs. Maybe he's injured because he's not running away from anybody. I'm going to see if he wants some bread crumbs. Have a nice weekend."

At that point she entered her apartment, and I rushed to my apartment to surf the Internet for this mysterious Ereu. Just one reference that it may be a type of a sandpiper but no pictures. Other sandpiper pictures look close, but my bird has almost no neck and a shorter beak.

I tried a site called http://whatbird.com, but after much time, the closest I come up with is a Midnight Heron.

Oh well, I give up, and chase the bird down with my camera. Hopefully, I didn't blind it with my flash. It's a smart bird, as soon as it heard the autofocus kick in again, it flew away. Can anybody help identify this?