WIP: CS-5432

First draft for optimizing backend search.

Please merge takeit's sql_optimize branch first.
If i call ?term=&foo=bar term is empty, not null, in that case i also don't want a results. I could check for empty() and is_null(), what do you think?