PeregrinTook
Registered User.
- Local time
- Today, 15:51
- Joined
- Aug 1, 2006
- Messages
- 15
Hey all,
I just found this article (http://www.applecore99.com/tbl/tbl004.asp) about indexes that talks about Access automatically creating two indexes on the primary key of a new table. I looped through the back end db of my app to return a list of indexes and associated fields for each table, and sure enough was surprised (perhaps wrongly??) at the results.
It looks like on any tables you create manually (ie thru clicking New Table Wizard), you do get two indexes on the table's primary key: one called PrimaryKey and one called the same as the actual field name. But on any tables you create through code (well using the SQL CREATE statement anyway) you get a single index called something like 'Index_CA67B281_435D_4772' on the primary key.
And because I've also added some indexes of my own through code (before I realised Access tried to help me), I now have quite a mess of indexes and reckon I should clean it all up a bit. So I'm thinking of just modifying the loop I made earlier to clear all existing indexes, then add new ones that I define from scratch - this should hopefully solve the problem. But in taking the time to do this, I want to make sure I get it right now. Therefore, what's the thoughts around indexes on tables:
I'm fairly sure any primary & foreign keys should be indexed as these are the primary identifiers when retrieving recordsets, but what about other fields though?
Would it be fair to say any fields included in a SQL WHERE clause should be indexed for example, to improve search speed?
Are there any other stand-outs like this that should always be indexed in a table?
Also, an index doesn't have to be called PrimaryKey on the actual primary key of a table, does it?
Is the name of an index relevant at all?
I would like to hear all thoughts as always...
Thanks
J
I just found this article (http://www.applecore99.com/tbl/tbl004.asp) about indexes that talks about Access automatically creating two indexes on the primary key of a new table. I looped through the back end db of my app to return a list of indexes and associated fields for each table, and sure enough was surprised (perhaps wrongly??) at the results.
It looks like on any tables you create manually (ie thru clicking New Table Wizard), you do get two indexes on the table's primary key: one called PrimaryKey and one called the same as the actual field name. But on any tables you create through code (well using the SQL CREATE statement anyway) you get a single index called something like 'Index_CA67B281_435D_4772' on the primary key.
And because I've also added some indexes of my own through code (before I realised Access tried to help me), I now have quite a mess of indexes and reckon I should clean it all up a bit. So I'm thinking of just modifying the loop I made earlier to clear all existing indexes, then add new ones that I define from scratch - this should hopefully solve the problem. But in taking the time to do this, I want to make sure I get it right now. Therefore, what's the thoughts around indexes on tables:
I'm fairly sure any primary & foreign keys should be indexed as these are the primary identifiers when retrieving recordsets, but what about other fields though?
Would it be fair to say any fields included in a SQL WHERE clause should be indexed for example, to improve search speed?
Are there any other stand-outs like this that should always be indexed in a table?
Also, an index doesn't have to be called PrimaryKey on the actual primary key of a table, does it?
Is the name of an index relevant at all?
I would like to hear all thoughts as always...
Thanks
J