Add an index only when the query filters, joins, or sorts on a field that is currently unindexed; if the filter sits on the wrong side of an expression, rewrite the query first, because the new index will not be used. A bad choice can turn a quick lookup into a table scan or a slow pass over linked data. This guide shows a query-by-query workflow to decide whether to add an index, rewrite the SQL, or leave the query alone.
Why is this Access query slow?
A slow Access query usually comes from one of three places: a missing index on a field used in WHERE, JOIN, or ORDER BY; a query shape that blocks index use; or linked-table traffic that is filtered on the Access side instead of the server side. In many databases, you can fix it in under an hour.
Local tables versus linked tables
On local tables, Access can use table indexes directly. On linked ODBC tables, it may pull more rows than needed and filter them locally if the query shape blocks pushdown. That matters because the same query can return in under one second with the right indexes and named columns, yet take 10 to 30 seconds when it scans a larger rowset over ten thousand rows.
Symptoms that point to a missing index
Look for a query that is otherwise simple: one table or a clean join, a selective WHERE clause, and a sort that matches the complaint. If the filter column is text, date/time, or a foreign key and the table has no matching secondary index, that is a strong index candidate. Access primary keys are already indexed, but secondary indexes are often the missing piece.
Symptoms that point to a bad query shape
If the query uses functions on the field being filtered, pulls wide rows with SELECT *, or repeats lookups in VBA, the index may exist and still not be used. In those cases, rewrite first. Access does not include a cost-based query optimizer like SQL Server, so it has less room to rescue a poor SQL shape.
Which fields should get an index?
Index fields used in joins, filters, and sorts first. Start with foreign keys, primary keys, and the most selective filter columns. Add multi-field indexes only when the same column combination appears together often, and leave low-cardinality fields alone when the index would be larger than the benefit.
Filter fields in WHERE clauses
If a query filters on a field that repeats less often than the table size suggests, it is a candidate for an index. A date range, customer ID, order number, or status code often qualifies. Low-cardinality fields such as Yes/No usually do not. Indexing a Yes/No field is almost always a performance-degrading operation.
Join fields and foreign keys
Foreign key fields are one of the most common missing index targets. If tblOrders joins CustomerID to tblCustomers, CustomerID should usually be indexed, and Access guidance recommends setting the field’s Indexed property to Yes (Duplicates OK). Relationships can create a hidden index for a foreign key, but do not assume every join field is covered unless you check.
Sort fields in ORDER
If the query sorts on one field, an index on that field can reduce work. If it sorts on several fields, a multi-field index may help when the sort order matches the index order. If the sort is on an expression, the engine may have to build a temporary result instead of reading an ordered index.
When multi-field indexes help
Use a multi-field index when a query repeatedly filters or sorts on the same field pair in the same order. For example, a Region plus OrderDate query can benefit if the pair is used together often. A multi-field index is less useful when the query uses only the second field by itself.
When low-cardinality fields should stay unindexed
Do not index fields with only a few repeated values unless they are part of a wider composite pattern that matters. A status field with three values, a gender field, or a Yes/No field can slow writes more than it helps reads. In small business databases, extra indexes can make inserts, updates, and deletes noticeably heavier.
When should you rewrite the query instead?
Rewrite the query when the problem is row shape, expression placement, or repeated lookup logic. An index only helps if Access can seek on the field. If the SQL asks for too much data, uses a function on the filtered column, or calls DLookup for every row, the structure is the problem.
SELECT * and wide row payloads
A query that only needs five columns should list those five columns. Narrowing the payload does not change the index rule, but it can cut the amount of data Access has to move and compare.
Memo fields and large text columns
Large text columns slow wide-table queries even when the filter is indexed. If the result does not need the Memo field, leave it out of the select list. If the query does need it, consider splitting the workflow so a summary query runs first and the detail row is fetched only for the final recordset.
DLookup in repeated row processing
DLookup in VBA can create a row-by-row lookup pattern with hidden round trips. That pattern is expensive because Access evaluates each lookup separately rather than letting the engine join once. Replace repeated DLookup calls with a join or a saved query whenever the lookup happens inside a loop or across many rows.
Expressions that block index use
Wrap a field in Left(), CDate(), DateValue(), Nz(), or another expression, and the engine often cannot use the index on that field. Rewrite the condition so the field stays bare on the left side of the comparison. If you need a computed value, consider a saved field or a separate query that computes it before filtering.
Suppose a query filters on CustomerID but also wraps it in Val(CustomerID) because the source column was imported as text. That expression can block index use. Changing the column type or fixing the comparison often helps more than adding a second index.
Access indexes to add first
Start with the primary key, then the foreign keys used in joins, then any selective WHERE or ORDER BY fields. Access stores primary keys as indexed fields, and secondary indexes can often provide substantial gains when the query shape can use them. Open the table in Design View and use the Indexes window to verify what already exists.
- Check the table design. Open the table in Design View and inspect each field’s Indexed property. Look for Yes (No Duplicates) on unique fields and Yes (Duplicates OK) on foreign keys or other repeated fields that are still selective enough to help.
- Open the Indexes window. Use the Indexes window to see existing single-field and multi-field indexes. Confirm that the query’s join and filter columns are actually covered before adding anything new.
- Add only the needed index. If a field is used in one slow query, add one secondary index and retest that query. Avoid stacking several indexes on the same table unless each one supports a real workload.
- Retest the exact query. Run the same SQL again after the change. If the query shape still blocks index use, the new index will not change much and you should rewrite the SQL instead.
A common first-timer mistake is indexing every field in a 20-table database after one slow report. That can make updates slower and still leave the report slow if the filter is wrapped in an expression or the join is missing a foreign-key index.
Jet and ACE engine differences
Jet is the engine used in pre-2007 MDB files. ACE is used in Access 2007 and later ACCDB files. Both benefit from indexes, but Access does not behave like SQL Server: it is commonly described as having a simpler optimizer, and ACE processes queries in memory while writing temporary results to the Windows TEMP folder.
Jet in MDB files
Jet uses rule-based execution behavior and has limited query planning. That means table order, expression placement, and index availability matter more than many users expect. A query that looks simple in the designer can still scan more rows than needed if the index cannot be applied cleanly.
ACE in ACCDB files
ACE improves some internal handling, but it still relies heavily on the SQL shape you give it. Because it processes queries in memory, large intermediate results can spill into temp files in the Windows TEMP folder. If those temp results grow, the file may feel heavier until you compact and repair.
When compact and repair helps
Compact and repair can help with bloat and with a file that has grown after many temp-result operations. It does not fix a missing join, a weak index, or a query that forces full scans. Treat it as maintenance, not as a root-cause fix.
Do linked tables need different optimization?
Yes. Linked tables often need a different plan because Access may filter locally while the server could have filtered sooner. If a query can be pushed down, the server optimizer can do more work and return fewer rows. If it cannot, Access may drag too much data across the connection.
Local filtering versus server-side filtering
With linked ODBC tables, the key question is whether the filter and join can be executed on the server. If Access pulls the whole table first and filters later, the query is slower than it needs to be. The same index that helps a local table may do little if the query shape blocks pushdown.
Pass-through queries
Use a pass-through query when the server should do the work and Access should simply display the result. That helps when the server has the better optimizer, the query is already valid in the server’s SQL dialect, and you want to avoid local Access planning limits.
Why the server optimizer can do more
A server optimizer can choose among plans, statistics, and join strategies that Access does not have. That matters on larger linked tables where a local Access query might be fine on 1,000 rows but slow once the server has to send many more rows than needed. If the source system can filter earlier, let it.
Access query checklist
Use this checklist to decide whether the query should get an index, a rewrite, or no change. Answer each item for the single slow query you are troubleshooting, not for the database in general.
| Symptom | Likely cause | Recommended fix |
|---|---|---|
| WHERE filters a field that is not indexed | Table scan on a selective column | Add a secondary index, then retest the exact SQL |
| JOIN uses CustomerID, OrderID, or another foreign key | Missing join index or hidden index not present | Index the foreign key; verify the relationship created the index if applicable |
| ORDER BY sorts a repeated column | Sort has no supporting index | Add an index if the sort is common and stable |
| Query uses functions on the filtered field | Index cannot be used | Rewrite the expression so the bare field is filtered |
| Query selects many columns with SELECT * | Wide row payload and extra I/O | Name only the needed columns |
| Memo fields are included but not needed | Large text increases row cost | Leave the Memo field out of the result set |
| DLookup appears inside a loop | Row-by-row lookup pattern | Replace with a join or saved query |
| Linked ODBC table feels slow | Local filtering instead of server-side filtering | Rewrite for pushdown or use a pass-through query |
| Table has a Yes/No or low-cardinality field | Index would not be selective enough | Leave it unindexed unless it is part of a useful composite index |
| Table is updated, deleted, or appended often | Too many indexes on a write-heavy table | Remove indexes that do not support a real query |
| Query is simple but still slow on over ten thousand rows | Missing key index or poor plan choice | Check joins and filters first, then verify the index is used |
| Compact and repair is the only fix being considered | Bloat, not query shape | Compact and repair after the query issue is fixed |
Should this Access query get an index?
Use about twelve yes-or-no checks. If you answer yes to several of the first items, an index is likely worth adding. If you answer yes to the expression, DLookup, SELECT *, or linked-table items, rewrite first and test again before adding more indexes.
- Does the query filter on one field? If yes, check whether that field is indexed already. If not, it is a strong candidate for a secondary index.
- Does the query join on a foreign key? If yes, make sure the foreign key is indexed, often with Yes (Duplicates OK).
- Does the query sort on one repeated field? If yes, an index may help the ORDER BY clause.
- Does the query filter on a unique field? If yes, the field should use Yes (No Duplicates).
- Does the query filter on a low-cardinality field? If yes, leave it unindexed unless it participates in a useful multi-field index.
- Does the query use a multi-field condition? If yes, consider a matching multi-field index in the same order.
- Does the query use an expression on the field? If yes, rewrite first because the index may not be used.
- Does the query use SELECT *? If yes, name only the needed columns before changing indexes.
- Does the query include Memo fields? If yes, remove them unless the result truly needs them.
- Does VBA call DLookup repeatedly? If yes, replace it with a join or a saved query.
- Does the query touch linked ODBC tables? If yes, check for server-side filtering or use a pass-through query.
- Is the table update-heavy? If yes, keep indexes to the minimum that support real queries, because extra indexes slow writes.
Say your orders table has about 200,000 rows and the report filters by CustomerID plus a date range. Index CustomerID first, then consider a multi-field index if that pair is used often in the same order. If the report still uses SELECT *, rewrite the column list before you judge the index result.
Frequently asked questions
Why is my Microsoft Access query so slow?
The usual causes are a missing index, a query shape that blocks index use, or linked-table filtering that happens locally instead of on the server. Queries over ten thousand rows can take 10 to 30 seconds when unoptimized, especially if they select too many columns or use expressions on filtered fields.
How do I add an index in Access to speed up a query?
Open the table in Design View, check the field’s Indexed property, and use the Indexes window to confirm what already exists. Set a unique field to Yes (No Duplicates) and a foreign key to Yes (Duplicates OK) when the query needs it. Then rerun the exact SQL.
Which fields should be indexed in Access queries?
Start with primary keys, foreign keys, fields used in WHERE clauses, and fields used in JOIN or ORDER BY clauses. A field that appears in the same filter combination often is a candidate for a multi-field index. Leave low-cardinality fields, including most Yes/No fields, unindexed unless a specific query proves otherwise.
Should I index foreign keys in Microsoft Access?
Yes, in most relational tables. Foreign keys such as CustomerID in tblOrders are a common missing index target, and relationships can create a hidden index when they are implemented. If the relationship is not in place, or if the field is still slow in a join, verify the index directly in the table design.
When should I not add an index in Access?
Do not add one when the field has low cardinality, such as a Yes/No field, or when the query cannot use it because the field is wrapped in an expression. Also avoid piling on indexes for tables that are updated often unless each index supports a real query. Extra indexes slow writes.
Do linked tables need different optimization in Access?
Yes. Linked ODBC tables may be filtered locally by Access unless the SQL can be pushed to the server. That is why pass-through queries can help: the server optimizer gets to do the work. If the linked query still drags back too many rows, rewrite the SQL before adding more local indexes.