I am creating a temp table with a query like this:
CREATE TEMPORARY TABLE temp_table
SELECT * FROM regular_table
WHERE 1
But regular_table has FULLTEXT index on some of the fields. I try to do a FULLTEXT search on the new temporary table and I get an error telling me “Can’t find FULLTEXT index matching the column list“. So obviusly the index is not copying over to the new table. Is there a way to force this?
Thanks.
You could use
CREATE TEMPORARY TABLE temp_table LIKE regular_table, but that will create all the indexes, so when you doINSERT INTO temp_table SELECT * FROM regular_table, the indexes will be rebuilt – which could be lengthy.Or, you can create the table and add the index afterwards:
but the index will be, again, updated on every insert.
Probably the most efficient way would be to create the temp table, insert all, build index afterwards:
Again, you will have to wait for the index to build, except it will happen in one chunk, with the last ALTER statement.