I'm using SQL Server 2008.
I've got a column NVARCHAR(MAX)
in a table which I want to make sure is unique.
The table has 600,000 records and grows every day by 50,000 records.
Currently before adding an item to the table I check if it exists in the table and if not I insert it.
IF NOT EXISTS (SELECT * FROM Softs Where Title = 'example example example.')
BEGIN
INSERT INTO Softs (....)
VALUES (...)
END
I don't have a index on the Title column
Recently, I started getting timeouts when inserting items to the table.
What would be the correct way to maintain the uniques?
If it would really help I can change the NVARCHAR(MAX) to NVARCHAR(450)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…