When he first strode into the saloon through the swinging doors, out of the blinding sunshine, the interior seemed dark as sin. All that met his senses was the music from an old upright piano, and the smell of sweat and whiskey. As his eyes became accustomed to the light, he gradually discerned the long mahogany bar, being polished in a desultory manner by a balding barman in a waistcoat, who eyed him surreptitiously.
‘Desperate’ Dan McGehee strode over to the bar. The dust of the desert trail had penetrated his soul. There was only one remedy. “I’ll have an orange Juice”, he muttered to the barman and placed his hat on the bar counter. The barman shot back a hostile glance.
“It’s whiskey, Scotch, straight, barley, corn, rye, bourbon, sour mash, or straight, mister.”
Dan looked around. At the end of the bar, a small gaggle of wranglers and cowhands had stopped their Grand Hazard dice game and stared impassively at him. The piano player sat on the piano stool swaying in time to the music of an old Irish ballad, and a couple of blowsy hussys leaned against the piano, nodding in time to the music. In the middle of the room, a smartly dressed group of local shopkeepers played poker around a table.
One of the cowhands slowly swaggered up to Dan. “Ah guess you ain’t from around these parts, stranger. ” There was a sudden flash of recognition.”Well I’ll be dawgone; So,” he started, sneeringly “it’s Desperate Dan McGehee, I see.” He leered and spat noisily into the sawdust. “Yew think you’re so danged quick on the draw with yaw answers to SQL Questins? But ah think you don’t know nuttin”. He swayed unsteadily.
The bartender put down the Sour Mash. “Take no notice Dan, it’s just the bourbon talking.” He looked anxious. “We don’t want no trouble with those goddamned SQL Quizzes or SQL Alphabets here.”
The cowhand plunged on regardless. “If you’re so damned smart, then see if you can answer this question.” He turned to his friends at the end of the bar and winked.
Dan looked up from his Sour Mash. He gently laid his hand on his ‘Staneck’ -SQL Server Administrator’s Pocket Consultant. “Just settle down friend, unless you want some ‘Best Practice’ bullet-points where the sun don’t shine.”
Suddenly, the bartender dived under the bar, and the piano player stopped playing and made for the rear exit of the room.
“OK Pardner” shouted the cowhand menacingly, “which isolation level do you choose in order to prevent dirty reads , phantoms and non-repeatable reads?”,
Before the words were out of his mouth, Dan had spat out “Serialisable!”. A look of startled surprise and disbelief flickered across the cowhand’s face until he fell, as if poleaxed, into the sawdust.
For a few seconds that seemed like eternity, everyone in the bar turned their pale faces towards Dan. There was a shocked silence. One of the wranglers started to creep up the stairs to the balcony.
“Well”, said Dan, “if that’s all the questions, I’ll take my leave of all you good folks”
“Not so fast!” said a cowboy, “With a distributed transaction, Under what circumstances are calls to remote stored procedures executed outside the scope of a local transaction?”
Dan glanced across, contemptuously. “If REMOTE_PROC_TRANSACTIONS is set to OFF, then the work done by the remote procedure is not rolled back if the local transaction is rolled back.”
There was a squeal from a brightly dressed girl by the piano, and, suddenly, the cowboy’s head slumped forward onto the mahogany counter. Slowly he slid off his chair to the ground.
Dan dusted himself down and started to put on his cowboy hat. Suddenly, from the balcony came a menacing voice. “What is a niladic function. Where would you expect to use it?” and another ” How does an independent subquery differ from a correlated subquery?” The critters were firing SQL questions from the balcony!
“Niladic functions don’t take parameters, pardner;” Spat back Dan, “and an Independent subquery is run only once whereas a correlated subquery is run for every row in the outer query.”
There was ghastly crash and a thud as a cowboy fell through the banisters. The saloon girls ran twittering and squeaking with fright to their bedrooms. One of the card-players looked up from the game of cards and stared reproachfully.
“Now looky here stranger,” said the severe-looking man, “You’re creating a goddam disturbance here with your quickfire SQL Answers. It’s time for you to ride out of town.”
“Eh? Who says?”
“Ahm the Sheriff in this town, and what ah says is the lawh.”
Suddenly, the entrance to the saloon darkened as a black figure filled the entrance. “I say you chaps, is everything all right? Spot of bother? Who’s game for a round of Nethergate Beer?” Everyone in the saloon gasped with fear. In the wild West, the name of ‘Phrenetic Phil’ Factor, the man with the silver bullet points, was legendary.
As the old song goes
‘Down in Arizona where developers hide,
and there’s no book to guide you save ‘The Dummies Guide’,
the roughest, toughest, man is still
that old ‘Phrenetic Phil’.
He speaks in verse (he speaks in verse)
In a convoluted doggerel or worse
In a meter and a scansion that’s perverse
Whist he answers SQL questions
He can even answer, rhyming, in a good split-second timing,
How they run, when they hear the fellow coming for the western folks all know,
He’s a versifying, death-defying, programming geek from East of Cambridge
Old Phrenetic Phil.
He was renowned for being the only SQL Quick-shooter who could answer SQL questions in verse.
“Take it easy, real easy!” spoke the sheriff, suddenly perspiring, “we’re peaceable folks around here, and don’t want no trouble”
All of a sudden, the stricken wrangler stirred himself in the sawdust, and, shaking his head, saw the looming figure of Phil . Before he could be restrained, he shot out the fateful words “OK, smart guy, what’s a clustered index, then?”
There was a breathless pause as every eye in the room swiveled to look at Phil. Without blinking he declaimed….
“If you make a clustered index on a table, as you should
and you choose the columns wisely then retrieval should be good;
for the order, at leaf -level of the table rows will be
In the order specified according to the clustering key
Data pages, doubly-linked, are in the list and hold the data
of the table, In this sequence, so it can be accessed later”
“Logical not physical, the order of the table rows
Not the order at disk-level , as a newbie might suppose
SQL Server doesn’t have to use a pointer to the table
For the index has the data so the database is able
to retrieve the data quickly from the data pages, so
If you choose your clustered index wisely, watch your queries go”
There was a groan, and the wrangler’s head once more hit the deck. A moment’s pause, then suddenly, the pianist was back at his post, attracted by the hypnotic rhythms of Phil’s verses. At first hesitant, and then with increasing confidence, the old upright jangle-box rang to the melody, until the occupants of the saloon burst into the Song of the Clustered Index, all animosities forgotten.
Later that evening, as the sun set behind the distant Mount Baldy, Phil and Dan set off once more down that long desert trail. ‘Time to be moving on, Phil,’ said Dan, contemplatively, ”cause a man’s gotta do what a man’s gotta do. Simple work; close to nature. Always on the move: Presentations, consulting work, SQL rodeo, bit of blogging” .
“Yes, but it’s a good life, leaving behind them ‘all hat and no SQL’ greenhorns; just as long as someone out there needs their data corralled; but I sure could do without those darned SQL Shootouts.” replied Phil as they rode on together into the night.