Reputation: 4132
I have a table now containing over 43 million records. To execute SELECT
, I usually select records with the same field, say A
. Will it be more efficient to divide the table into several tables by different A
and save in the database? How much can I gain?
I have one table named entry: {entryid (PK), B}
, containing 6 thousand records, and several other tables with the similar structure T1: {id(PK), entryid, C, ...}
, containing over millions of records. Do the following two processes have the same efficiency?
SELECT id FROM T1, entry WHERE T1.entryid = entry.entryid AND entry.B = XXX
and
SELECT entryid FROM entry WHERE B = XXX
//format a string S as (entryid1, entryid2, ... )
//then run
SELECT id FROM T1 WHERE entryid IN S
Upvotes: 0
Views: 202
Reputation: 14953
But it would be the best to measure your results because it may depend on your hardware coonfiguration, indexes (use EXPLAIN to check if you have correct indexes), your MySQL settings like query cache size, and engine you are using (MYISAM, InnoDB)...
Upvotes: 1
Reputation: 8473
Use the EXPLAIN Command to check your queries. dev.mysql.com/doc/refman/5.0/en/explain.html
Here is an explaination http://www.slideshare.net/phpcodemonkey/mysql-explain-explained
You need to make sure first and foremost you have the right indexes for a table that size especially for queries that join with other tables.
Upvotes: 0