MySQL Proxy

Over the last weeks I wrote a mysql-proxy which changes the way you operate with the MySQL Server.

client to server

A proxy can operate as Man in the Middle and pass through to network packets to the MySQL Server, but it also change the packets when needed. This opens the several possibilities ...

more ...

MySQL Proxy, reverse mode + source

The MySQL proxy got some final touches to make it ready for the first release:

  • a command-line interface
  • some more mode descriptions for the different modes of operation

You can choose between three modes for now:

  • pseudo server
  • injection proxy

injection proxy * replication client

replication client

For the future we plan:

  • connection pooling

connection pooling * replication ...

more ...

Trees in SQL

The problem of how to handle trees in SQL has been talked about alot. The basic 3 ways are:

  • store the full path for each entry
  • store the parent for each node
  • use nested tree

Nested tree is good for read-many-write-less applications where the tree doesn't check over time ...

more ...

Analyzing complex queries

When you ask someone how to optimize SQL queries you will always get the answer

  • enable the slow query log
  • set the long-query-time to 1-2 seconds
  • enable the logging of query which aren't using an index
  • run EXPLAIN on the queries that are shown and optimize them with proper ...
more ...

groupwise max

... or "How to solve the same problem in 10 different ways".

One of the common problems to solve in SQL is "Get row with the group-wise maximum". Getting just the maximum for the group is simple, getting the full row which is belonging to the maximum is the interesting step ...

more ...

ORDER BY RAND()

If you read the MySQL manual you might have seen the ORDER BY RAND() to randomize the the rows and using the LIMIT 1 to just take one of the rows.

SELECT name
  FROM random
 ORDER BY RAND()
 LIMIT 1;

This example works fine and is fast if you only ...

more ...