Biank (3/21/2013)
I'm trying to create indexes on a table that will hold all of data changes in any columns of any tables so the number of rows will be pretty big.Here's the table structure:
ID int identity
chg_type char(1) not null
tbl_nm varchar(40) not null
p_key_nm varchar(40) not null
p_key_id id not null
col_nm varchar(40) not null
old_txt varchar(1000) null
net_txt varchar(1000) null
mod_dt datetime not null
mod_by varchar(50) not null
One audit table to rule them all? You've just created one HECK of a contention point for your entire database. Make sure you turn on deadlock notices, you may need them. Also start monitoring for what's called 'hotspotting' your tables. There's a lot out there on google for that term.
I created index like this:
1. PK on ID column
2. Non-Unquie NC on p_key_id, tbl_name includes old_txt and new_txt
3. NC on mod_dt, mod_by
PK is Clustered or nonclustered? Use what you like for the key, but I recommend a tight clustered index which is your most common search patterns. Also, for mod_by, are your users going to the database to directly edit or do you use a front end application? If it's a front end, they almost always all use the same login, you won't have any detection of the user(s).
... I've never tried this tactic because of how painfully most of my systems would react if every table had to contend with a single location for auditing simultaneously on every transaction.
I would truly recommend you review a different design method. Once you get any serious throughput on this system you will feel tremendous amounts of pain.
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA