Tips and tricks for writing SQL in different DB servers.

Stupid monitoring trick: Watch mysql queries fly

Put this somewhere in your ~/bin:
watch ‘echo “show processlist” | mysql -u whateveruser –password=mypassword | grep -v “show processlist” ‘
Now run it and you will have a poor man’s monitor, kind of like top but for MySQL. That coupled with screen (or multiple terminals) may give you some quick and easy piece of mind.

This […]

Oracle tuning: Using Hints

Every once in a while you will get a query that no matter what you try, it doesn’t use the indices. This is typically because the cost-based optimizer decides that an approach that is slower has a total cost that is lower than using the index and making it faster. To solve this, you would […]

By |June 20th, 2005|CBBTR, SQL|Comments Off

Oracle tuning: Using explain plan

In order to make queries run faster, you should try to have oracle explain to you how the query should be performed. The whole explanation for oracle tuning can be found on the Oracle Tuning guide, but here are the basics.

By |June 20th, 2005|CBBTR, SQL|Comments Off

MySQL: Create/Drop DB and user

This tip contains a couple of MySQL scripts that allow me to create and drop a database and a user that will “own” said database.

By |April 5th, 2005|CBBTR, SQL|Comments Off