I am creating a multi tenant db for an application. I have gone with the TenantID in every table approach and it works very well. I am at the performance tuning stage.
My question is should each TenantID in every table be indexed for optimized searching as every query on the db will filter on this column?
Look forward to any advice.
Thanks
Although there are many considerations you need to make when indexing, In my experience, the (unique) clustered index works well as
tenantId + PKAll PK queries can seek on the composite key.This has the added advantage of putting the tenantID in your nonclustered indexes as SQL Server uses the clustered key as the reference back to the table from the nonclustered indexes.
Watch out for page splits though, since inserts will almost always be mid page, this approach definitely optimizes for reads. Consider a fill factor of 70 and watch your fragmentation, be sure to have regular index maintenance in place (you want this anyway)
Best of luck.