Re: Database design question
Posted in 1996
Neil Truby <ntruby@netcomuk.co.uk> wrote: :I have a table on a bought-in application with about 350,000 rows. It :has a column defined as an index You mean there is an index created on this column alone? :, but in fact the column contains :contains nothing for any row. Therefore every one of the 350,000 rows :has the same index value, which is clearly undesireable. However, what :the design is clearly meant to achieve is fast selection of a single row :when the column has a non-null value. :Any hints or tips for this? If there are nothing but null values may be there will never be anything else. In that case you should simply drop the index. If you want to retain the index so it can be used when some row gets a value you can drop the index and recreate it as a multi column index starting with the same column and then include the primary key of the table. If the primary key is multi column or a large column you might want to include another column that is near unique over the table. In this way you will avoide the problems with the index containing only one value, and it can still be used if a column should ever get some value. You'll of course have to remember to run update statistics medium or high on this column so the optimiser can be aware of the data distribution and use the index intelligently. Nils.Myklebust@idg.no NM Data AS, P.O.Box 9090 Gronland, N-0133 Oslo, Norway My opinions are those of my company