I’m creating a MySQL MyISAM (Full textual searches are needed) table.
- column_1 – contains a TEXT primary key (Data will be a 64 bit encoded string)
- column_2 – references another table and is used for joins
- column_3 – another TEXT column indexed for searches using MATCH
- …
The table is likely to hold billions of records over time.
column_1 main search would be performed on the primary key column as follows. e.g.
SELECT * FROM table WHERE column_1 = 123;
column_2 main search would be performed as follows:
SELECT * FROM table_1
JOIN table_2 ON ( table_1.column_2 == table_2.id );
column_3 main search would be performed as follows:
SELECT column_3, MATCH ( column_3 )
AGAINST ( 'TOKEN' ) AS score
FROM table_1;
I would like to take advice on the sort of indexes I would need to setup and any other advice that sounds relevant.
Thanks in advance.
P.S
Am I right in thinking that if you do a search e.g.
SELECT * FROM table WHERE id = 1; (where id column is not indexed)
The search on a substantial db would be slower than if the column was indexed?
You are right in your final assumption. The index is made up by a data structure specifically tailored for searching in, with the column as key and a pointer to the correct row as the value. A search on a non-indexed field will require a full table scan (making the db examine every row of the table).