Background: I have 2 tables (let’s call them tblParent and tblChild) with enforced RI on the 2 common fields. The child table has about 115,000 records in it. We have a delete query that was deleting records from tblParent for which there were no records in tblChild. It was taking about 2 minutes on a very fast computer to delete just 30 records in the parent. We added a new index on tblChild that indexed these 2 fields, and the delete then took virtually no time at all.
The problem is that this should not be necessary! When you create a relationship between 2 tables and enforce RI, Access creates a hidden index on the child. Access should be able to use this index to optimize queries.
Access names this new index by combining the 2 table names, so in the case above it should have been “tblParenttblChild”. Using my Documentor utility, I found that the index name wasn’t what was expected, but rather it was some sort of system-generated name, probably some combination of table addresses or something. So, I deleted that new index we had created and deleted and then recreated the relationship between the tables. The delete query then ran virtually instantaneously, and when I checked the hidden index, it was again named “tblParenttblChild”.
After doing some more experimenting, I found that importing tables and relationships causes the hidden index names to be changed! Although the table integrity is still maintained, apparently Access can no longer use this index for other situations. This can have a serious impact on performance, as we noted. And since importing all tables into a fresh database is one of the standard procedures for clearing-up problems, it is probable that everyone has this problem! How much of a problem it is will depend on many factors, including table size.
For my own part, if I have to import tables, I will NOT import the relationships. Even though it is a pain, I will manually recreate them.