Only creates index on variable type table for MySQL

Split the index creation into a separate function. For psql, the
function is no-op; for MySQL, create the actual index. This function
can be extended to future similar cases.