Sunday, July 18, 2010

A View Of Taishan

By Du Fu

What shall I say of the Great Peak? --

The ancient dukedoms are everywhere green,

Inspired and stirred by the breath of creation,

With the Twin Forces balancing day and night.

...I bare my breast toward opening clouds,

I strain my sight after birds flying home.

When shall I reach the top and hold

All mountains in a single glance?

Sunday, July 11, 2010

My Country

By Dorothea Mackellar (1885 - 1968)


The love of field and coppice,

Of green and shaded lanes.

Of ordered woods and gardens

Is running in your veins,

Strong love of grey-blue distance

Brown streams and soft dim skies

I know but cannot share it,

My love is otherwise.

I love a sunburnt country,

A land of sweeping plains,

Of ragged mountain ranges,

Of droughts and flooding rains.

I love her far horizons,

I love her jewel-sea,

Her beauty and her terror -

The wide brown land for me!

A stark white ring-barked forest

All tragic to the moon,

The sapphire-misted mountains,

The hot gold hush of noon.

Green tangle of the brushes,

Where lithe lianas coil,

And orchids deck the tree-tops

And ferns the warm dark soil.

Core of my heart, my country!

Her pitiless blue sky,

When sick at heart, around us,

We see the cattle die-

But then the grey clouds gather,

And we can bless again

The drumming of an army,

The steady, soaking rain.

Core of my heart, my country!

Land of the Rainbow Gold,

For flood and fire and famine,

She pays us back threefold-

Over the thirsty paddocks,

Watch, after many days,

The filmy veil of greenness

That thickens as we gaze.

An opal-hearted country,

A wilful, lavish land-

All you who have not loved her,

You will not understand-

Though earth holds many splendours,

Wherever I may die,

I know to what brown country

My homing thoughts will fly.

Sunday, July 4, 2010

Correlated Subquery

The NULL issues discussed in the previous entry on subquery can be side-stepped with correlated subqueries. Correlated subqueries are different to subqueries in that for each outer row, the query tries to find a matching inner row. If such an inner row exists, then the outer row is returned. For example,
select *
from t1
where exists
(select *
from t2
where t1.a_col = t2.a_col);

The above query can be optimized as follows:
select *
from t1
where exists
(select '1'
from t2
where t1.a_col = t2.a_col);

Notice that the inner query projects the value '1' if there is a match instead of the whole row, which could have dozens of columns.

What happens if the WHERE clause has NOT EXISTS instead of EXISTS, and the inner query returns NULL? In that case, the outer query returns nothing, which is the expected behavior. Presto, the perils of NULLs are nullified!

Sunday, June 27, 2010

Subquery And Null

Last week, I completed a four-day Teradata Advanced Sql course offered by Teradata Australia Pty Ltd and sponsored by my employer. In this series, I will document some of the insights that I gained and the tricks of the trade that I learnt. Today, I will write about some gotchas associated with subqueries.

The following is a garden variety subquery that I write all the time:
SELECT *
FROM t1
WHERE some_col NOT IN (SELECT a_col FROM t2);

The above works as long as the subquery does not return a NULL in what is effectively a comma separated list of values within the pair of parenthesis. However, things go pear-shaped if the subquery returns one or more NULLs in the list. When that happens, the outer query returns nothing.

The outer query compares some_col with each value returned by the subquery.  Say, the subquery returns val1, val2 and NULL. For the outer query to return a row, the condition that needs to be true is this: 
some_col not equal to val1
AND some_col not equal to val2
AND some_col not equal to NULL;

Comparison with a NULL results in NULL, and so does ANDing a value with a NULL. Therefore, the preceding condition never becomes true, and the outer query does not return anything.

NULL is not an issue in the following query (it has 'IN' instead of 'NOT IN' in the WHERE clause):

SELECT *
FROM t1
WHERE some_col IN (SELECT a_col FROM t2);

In the above query, some_col needs to be equal to only one of the values returned by the subquery for the outer query to return a row. In other words, some_col gets ORed with the values returned by the subquery. Therefore, NULL is not an issue.

There are ways to circumvent the problems caused by NULLs in a subquery, and they will be discussed in the next installment of this series.

Sunday, June 20, 2010

Returning At Night To Lumen Mountain

By Meng Haoran

A bell in the mountain-temple sounds the coming of night.
I hear people at the fishing-town stumble aboard the ferry,
While others follow the sand-bank to their homes along the river.
...I also take a boat and am bound for Lumen Mountain --
And soon the Lumen moonlight is piercing misty trees.
I have come, before I know it, upon an ancient hermitage,
The thatch door, the piney path, the solitude, the quiet,
Where a hermit lives and moves, never needing a companion.

Monday, June 14, 2010

Can Israel Folau Beat the 10k Rule?

Malcolm Gladwell, author of the international bestseller The Tipping Point (2000), pored through reams of research data compiled by economists, psychologists and social scientists to construct a simple formula for becoming a genius in his 2008 book Outliers: The Story of Success. Gladwell's own genius lies in teasing out previously unsuspected patterns and relationships from jumbles of arcane academic data, and weaving them into simple narratives accessible to the lay audience. His insights into the makings of a genius can be summarised as follows:

  • True mastery in any complicated field requires 10,000 hours of conscious practice

  • Geniuses such as Bill Gates, Bill Joy and the Beatles received their apprenticeships through a combination of good fortune and conscious effort

  • The popular myth of a genius as a solitary figure fighting alone against the prevailing currents of society is just that, a myth. Most geniuses receive family support and community patronage during their formative years


A couple of weeks back, at the height of the media frenzy sparked by National Rugby League (NRL) superstar Israel Folau's six-million dollars defect to the rival Australian Football League (AFL), Channel 9's sports program Wide World of Sports re-played Folau's interview from a year back.

Many NRL fans regard Folau, a towering, powerfully-built young centre-winger whose gravity-defying jumps and electrifying bursts near the try line captured the imagination of NRL fans and excited the predatory instincts of AFL poachers, as a natural talent and born athlete. In the interview, Folau bristled at this notion, reminiscing about getting up at 5am in the mornings as a kid and being driven to trainings by his dad when most kids his age would have been sleeping like angels.

If Folau is not a natural talent, then I suppose no one is.

Another famous 'natural' talent, at least in the minds of sports fans, was Michael Jordan, who could perhaps teach even Folau a thing or two about gravity-defying jumps. However, many sports fans are unaware that Jordan could not even get picked for his high school basketball team. What Jordan did after being snubbed thus was practise, practise and practise until he had presumably clocked over 10,000 hours of conscious practice.

The operative word here is 'conscious'. Practice must be informed by a conscious, deliberate effort to improve, which more often than not entails seeking critical appraisals from mentors, coaches and peers, creating a positive feedback loop. This perhaps explains why many clubhouse chess players get stuck in a rut despite many years of weekend skirmishes, or most aspiring footy players fall by the wayside,  never graduating from park footy.

According to research, this 10k hours rule is quite general and applies across diverse non-trivial human pursuits such as music, mathematics, computer programming and writing.

Of British-Jamaican heritage, Gladwell, who currently writes for The New Yorker, is on the record saying that he completed his 10k writing apprenticeship working as a journalist, in which role he would have received feedback from experienced copy editors on his craft. He closes Outliers with his own chequered family history to buttress his thesis that family and the wider community play a vital role in the development and emergence of a genius.

Given that any non-trivial skills set requires 10k hours of practice to master, University of Sydney's David Anderson, a skills acquisition specialist who was quoted in a Sydney Morning Herald article on June 5-6, cast serious doubts on the ability of Folau to transfer his NRL skills to AFL, which is governed by a completely different set of rules and patterns of play.

Athletes with brute physical strength and ability to run short distances at explosive pace tend to thrive in NRL. AFL is more of an endurance sports requiring kicking skills absent in NRL and the temperament of a long distance runner. Then, there is that undefinable knack for reading the game, which separates elite players from merely good ones.

"They (NRL players) can run fast and they're big and strong, they can pass and catch and kick, but what they can't do is read the patterns of play and that puts them at a massive disadvantage," Anderson was quoted as saying. The article also pointed out the obvious: Folau and his fellow AFL convert Carmichael Hunt will simply not have enough time to log 10k hours of practice, which roughly takes around 10 years in real life, before the show begins.

Will Folau defy the 10k rule and prove his doubters wrong to have a productive AFL career, or will he, too, join the rank of other code-switching NRL stars such as Wendell Sailor, Lote Tuqiri and Timana Tahu, all of whom came back to NRL after disappointing stints at another rival footy code?  Only time will tell.

Sunday, June 13, 2010

City2Surf 2010: Running for Fun & Charity

City2Surf

I am taking part in this year's City2Surf fun run to be held on Sunday, August 8. The run starts at Sydney's Hyde Park at the heart of the city and ends 14.1km later at Bondi Beach in the eastern suburbs. This will be my third participation in this event, which is regarded as the world's largest fun run. More than 75,000 people took part in it last year.

This year, I am raising funds for RSPCA, which is Australia's only truly national animal welfare organization. If you can, please help me raise funds for RSPCA via my HeroPage here. Your tax-deductible contributions will help RSPCA accept and take care of unwanted animals and investigate cases of animal cruelty.

rspca