BREAKING COMMIT: This is a hack to address slow queries
BREAKING COMMIT: This is a hack to address slow queries

TShank sometimes wants to know what columns a ConceptQL statement
returns.  The ConceptQL SQL query is run against the database
with a LIMIT 1 tacked on the end.  In some cases, this throws
PostgreSQL into a tizzy and it takes 2000x longer to run
the LIMIT 1 query than without it.

This wraps all ConceptQL operators in a CTE that is materialized
so that the query planner will ignore the LIMIT 1

There are probably negative effects on other types of queries.

UNION doesn't seem to be working in all cases.

Still, this is a good stop-gap for the short-term

outcomesinsights/conceptql,outcomesinsights/conceptql