First query is slow. 2nd one is fast. why?

Hey! The reason for this is almost certainly that MemSQL JIT-compiles queries, so that the first time you run a particular query shape, it takes a while, but then subsequent queries are fast.

See also 10-15 seconds of pre-compile - #10 by jack.