perf: Use a materialized view to speed queue views

This patch introduces an automatic materialized view to speed database
performance when querying and displaying the ticket views. This can
eventually be extended to the search and advanced search features to speed
them as well.

The data from the dynamic form entries related to ticket details is copied
to a %ticket__cdata table. The %ticket__cdata table is then joined directly
to the other tables in the query for the ticket view. MySQL is magically
and dramatically faster using this method.

The downside is that the disk usage for the custom data is doubled, and the
time needed to update the dynamic data is at least doubled as the form
entries and the materialized view must both be updated.

This method should also extend well to other database platforms in the
future. It will be likely that most other database query optimizers will
have difficulty joining, scanning, and sorting the table models we have for
custom data fields.
Improve advanced search performance

Use a union query to avoid using DISTINCT and lots and lots of joins in the
from clause.

Initial tests seem to indicate about a 80% faster (~500ms down from ~800ms)
on querying about 9k tickets).
Fix up search on dynamic fields

Fix adding fields to an existing form
Merge pull request #357 from greezybacon/issue/ticket-queue-performance

perf: Use a materialized view to speed queue views

Reviewed-By: Peter Rotich <peter@osticket.com>