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!