Tuesday, September 25, 2007

How stock markets work!!!

It was autumn, and the Red Indians on the remote reservation asked their New
Chief if the winter was going to be cold or mild. Since he was a Red Indian
chief in a modern society, he couldn't tell what the weather was going to
be. Nevertheless, to be on the safe side, he replied to his Tribe that the
winter was indeed going to be cold and that the members of the village
should collect wood to be prepared. But also being a practical leader, after
several days he got an idea. He went to the phone booth, called the National
Weather Service and asked 'Is the coming winter going to be cold?' 'It looks
like this winter is Going to be quite cold indeed,' the meteorologist at the
weather service Responded.

So the Chief went back to his people and told them to collect even more
Wood. A week later, he called the National Weather Service again. 'Is it
going to be a very cold winter?' 'Yes,' the man at National Weather Service
again replied, 'it's definitely going to be a very cold winter.'

The Chief again went back to his people and ordered them to collect every
scrap of wood they could find. Two weeks later, he called the National
Weather Service again. 'Are you absolutely sure that the winter is going to
be very cold?' 'Absolutely,' The Man replied. 'It's going to be one of the
coldest winters ever.'

'How can you be so sure?' the Chief asked. The weatherman replied, 'The Red
Indians are collecting wood like Crazy.'

This is how stock markets work!!!

Monday, September 10, 2007

myisamchk - checking and repairing myisam tables in mysql

First of all, how and why does a mysql table go corrupt?

Tables generally go corrupt when mysql server crashes and the tables are not closed properly. They remain in an inconsistent state when mysql is again restarted. What generally happens when a table gets corrupted is that the index file (.MYI) and the data file(.MYD) do not synchronize properly. So there might be some records in the data file for which index entries are not proper.

I have also seen cases where the table goes corrupt just like that. Which might be due to
a) the disk being bad
b) some bug in mysql leading to inconsistent reads and writes.

And one of the ways to repair corrupted mysql (MYISAM) tables is to use the myisamchk utility.

Generally i would do the following (sweet and simple)

mysql> CHECK TABLE ABC;
mysql> REPAIR TABLE ABC;

But there are cases when these queries fail to recover the table. I had a case where "REPAIR TABLE" used to give me "OK" but "Check table" used to give me "table marked as crashed". To recover from such cases the only method to use is the myisamchk utility.

./bin/myisamchk [options] ./data/<database_name>/<table_name>.MYI

A myisamchk --help would list down all the options.

Note: No other program should be accessing the table when myisamchk is repairing a table. I prefer to turn off the mysql on the machine where table is corrupted unless it is repaired.

The best option for full recovery is --safe-recover. Which can be used to repair tables which cannot be repaired by any other option. If the table cannot be repaired using this option then you might have to give up on the table.

But --safe-recover takes up a lot of time.

The way to speed up myisamchk is to increase the buffers that it uses to read, write and process.

--read_buffer_size and --write_buffer_size is used to read and write data from the table and to the temporary file.

--sort_buffer_size is used when the keys are repaired by sorting keys, which is the normal case when you use --recover

--key_buffer_size is used when you are checking the table with --extend-check or when the keys are repaired by inserting keys row by row into the table, that is using --safe-recover option. Repairing using the key buffer is slower and also takes much less disk space as compared to sorting.

To speed up table repairing use large values for key buffer and sort buffer. Both values can be made very large cause only one of them is used at a time.

Eg: myisamchk --key_buffer_size=512M --sort_buffer_size=512M --read_buffer_size=8M --write_buffer_size=8M ./path/to/database/table.MYI

Wednesday, September 05, 2007

legends cannot be remade

Yup thats true. You cannot remake legends. The originals are still the best. Why am i saying this? Well, recently i had a chance to watch the recently remade bollywood legend "sholay" - "Ram Gopal Verma ki AAG".

There has been remixes of all types of classic old songs. And remix videos with all "beautiful" gals dancing here and there. And yes upto some extent i tend to like them. But i cant hear them for ever. I can hear those remixes for some time. But the original songs are still the best and can be heard again and again.

There was the remake of the bollywood and amitabh bacchan classic - "DON" starring shah rukh khan. And it was not that good. The remake had one good quality that in the new version of "DON" - bad wins over good as opposed to the original version where good wins over bad. So though the movie was not that good the climax saved the movie and it did make some news. People liked it.

But then, what is wrong with "AAG"? Let me put it this way - it is a terrible mix of old and new. The movie is simply a very bad version for sholay. You cannot replace "Gabbar Singh" with "Babban" or "Thakur" with "mohanlal" or "Veeru" with "Heero" or "Jai" with "Raj" or "Basanti" with "Ghungroo" or "Dhanno" with "Laila". The original characters and their names were the best suited. Babban and mohanlal does not ring at all. Nor could you modernize the dialogues

Orignial - "Kitne Admi the?"
Remake - "Kitne ... Kitne"

It just does not ring. The final fight sequence is also very sick. And the mix of original sound track with modern sound track during the final fight sequence makes things terrible. You cannot remove thakur's fingers instead of his hand. And of course the thakur has to kill gabbar with his special shoes (with nails) rather than kill him with an axe or whatever...

Earlier bollywood movies used to be remakes of origial hollywood movies. Like the recently hit "Partner" was a remake of "Hitch". Though i enjoyed the orignial hollywood movie a lot more than the remake. But it still did make sense for those audience who do not watch or do not understand the hollywood movie/culture/language. But remake of a hindi original does not make sense at all.

It seems that the bollywood directors and producers and script writters have run out of new and fresh ideas and have also run out of more hollywood movies to remake. Though there a lot of hollywood moives which could be remade still... Or maybe, they are just tired of remaking hollywood movies.

Hope that "Victoria No 203" remake is better... Will watch it soon.