I need to find all indexes available on a query.
I have a datatable, with filters on top of each column, but I want to enable filters only for indexed columns.
For this I have a main query to which when a value in any filter is added a clause is added.
I need to find all the indexed columns available on this main query.
I will use this info to only show column filters on indexed columns.
Main query looks like this, there book.title
and author.name
are indexed columns in there respective table and pages and genre are not, thus column filter will only appear on book.title
and author.name
.
SELECT book.title, book.pages, author.name, author.genre
FROM books_table as book
JOIN author_table as author ON author.id = books.author_id;
I need to figure these indexes dynamically. I have many many queries like this and do not want to do it manually, doing it manually also will need changes in code when indexes are are added or removed.
if it matters, my database is Mysql 5.6
Thanks