Merge request searches respond with 500 on some queries

Summary

Some of the dashboard merge requests queries end up with a 500 error. It happens because they aren't optimized, but had to iterate over a lot of data.

Steps to reproduce

Visit:

What is the current bug behavior?

The page displays 500 error because the query fails with timeout

What is the expected correct behavior?

The page returns correct results

Possible fixes

We can forbid using particular queries alone because listing all Draft merge requests or all merge requests without labels in the environment doesn't seem useful. We can return the same pages as for:

https://gitlab.com/dashboard/merge_requests?scope=all&utf8=%E2%9C%93&state=opened&not[assignee_username]=igor.drozdov

See Database statement timeout loading merged branc... (#373190 - closed) for possible fix to speed up query

Edited by Jay McCure