January 29th, 2008

amazon

You can't photograph the building, inside or outside

The MySQL PS gig I'm working this week is in Dallas, inside a really cool looking building with the really lame name of "Infomart". The building itself is a very obvious homage to the old Crystal Palace.

When I saw it, I knew what my project365 picture of the day was going to be for a few days.

Today, I came in early, and set my camera up on it's tripod for a great shot up the interior at the stack of 6 escalators, when some rentaguard came up to me.

Sir! Can I ask you why you are taking pictures of the building!?

Because it's a cool looking building.

I'm sorry, sir. You can't photograph the building. Inside or outside.

Ok. And I fold up the camera and put it away.

Morons. I'm sure it's policy that the guards are tasked with enforcing, but it's an idiotic and moronical policy. And forbidding photographing the outside is not only stupid, it's not even legally possible. I'm still going to take that picture. And a picture of the glass fountain next to me right now. And a picture of the outside.
amazon

SQL. Find probably useless indexes.

A useful SQL query I worked out yesterday.

It finds all the indexes in the database "my_database" that have a cardinality/count ratio of less than 0.1%

Such indexes are probably not very useful, and should be looked at carefully to justify their existence.


use information_schema;

select tables.table_name, statistics.index_name, statistics.cardinality, tables.table_rows

  from tables

  join statistics

  on (statistics.table_name = tables.table_name

   and statistics.table_schema = 'my_database'

   and ((tables.table_rows / statistics.cardinality) > 1000));



I worked this out on my current MySQL PS gig. The client has indexes on nearly every column of nearly every table. For example, all of their customers are in Texas, but they still put an index on the "state" column in the address table.