Implement strbuf and use it in sdb_query for O(n) instead of O(n^n) times