In sqlite, I can run a command like:
EXPLAIN QUERY PLAN SELECT employee FROM employees WHERE manager = 'joe'
and get something like:
QUERY PLAN
`--SEARCH employees USING COVERING INDEX sqlite_autoindex_employees_1 (manager=?)
which tells me how the primary key index is being used to perform that query. (primary key is composite in this case)
In Haskell's sqlite-simple library, I am familiar with the query and query_ functions,
query :: (ToRow q, FromRow r) => Connection -> Query -> q -> IO [r]
query_ :: FromRow r => Connection -> Query -> IO [r]
Which could run a string-defined query, but their return type of FromRow r => [r] precludes them from being able to compile a Query Plan, for which the return type would have to be something like another string. When I try to compile one I get this error:
No instance for (FromRow Char) arising from a use of ‘query_’
There are some other variations on query and query_ in Database.SQLite.Simple, but I do not see one which looks like it could return a string, or otherwise, the result of a query plan request.
Is there any way to run an sqlite query plan from Haskell?