Writing a high performance database engine