Reputation: 3078
I need to prevent table scan on a big table where a search of a record is based on three fields, one of which may be updated. The searching query looks like this:
select blabla from ttg_transaction where uti = ? and txn_type = ? and state = ?
The index that comes to mind (not unique, not clustered) would the three fields above. But while the first two are constant, 'state' does change during the life cycle of a record.
Is this a good reason to exclude 'state' from the index?
Upvotes: 2
Views: 710
Reputation: 6111
Things that would make this a bad idea
Or a combination of these.
Assuming you have fast storage, I wouldn't worry to much. If you still have slow storage you could
To profile you can use SET STATISTICS IO ON
and/or SET STATISTICS TIME ON
To handle index fragmentation you could specify a fill factor that makes sense for your case.
If state is random text field this could interfere with your statistics as well, but you didn't specify.
Upvotes: 2