Hello again Stackoverflow…
My organization is using SugarCRM for internal process handling. We are in the process of importing approx. 27Gig worth of MsSQL data into select tables. As I was working along one of the tables called accounts_contacts is an intermediary table linking ‘accounts’ to ‘contacts’ (surprise). HEre is the table structure:
Name Type Collation Null Default
id varchar(36) utf8_general_ci No None
contact_id varchar(36) utf8_general_ci Yes NULL
account_id varchar(36) utf8_general_ci Yes NULL
date_modified datetime Yes NULL
deleted tinyint(1) Yes 0
Demo data:
0001391a-9d28-4bd0-9cec-f469cd244ca7 19135ac7-d47c-e111-b389-1cc1dee8bacd 1a135ac7-d47c-e111-b389-1cc1dee8bacd 0000-00-00 00:00:00 0
000262b6-a0ef-48de-b0f6-47db097b35d6 43080e24-a24d-e111-8cf6-1cc1dee8aa73 44080e24-a24d-e111-8cf6-1cc1dee8aa73 0000-00-00 00:00:00 0
00042aa7-39cd-4fcb-9f47-dc2b31c69a11 e9764a4d-d921-e111-8e18-1cc1dee8bacd ea764a4d-d921-e111-8e18-1cc1dee8bacd 0000-00-00 00:00:00
At the moment said table rests at approx. 55k rows.
My question: for speed and performance, at what point would this table warrent an index of contact_id and account_id?
I would say, a combined index on contact_id and account_id will give you immediate performance boost for joining accounts and contacts. The only reason for not adding an index to a table is the overhead of keeping the index in sync on table data inserts/updates. So if you have many writes to that link table, you should benchmark the effect on an index. Otherwise, if you mostly just read from that table – create an index.