Indexing Strategy for NVARCHAR(MAX) Columns

Posted on 2011-10-09
Last Modified: 2012-05-12
Hi all,

First of all, I am trying to parse Exchange 2007 Message Tracking log files straight into SQL for querying/trending information. So far I am making good progress.

I am wondering what is the best strategy for indexing some of my columns that use the NVARCHAR(MAX) data type?

I have created a CLUSTERED INDEX on my Primary Key column which is an auto-incrementing identity column that adds 1 to the ID each time.

I have also created some NONCLUSTERED INDEXES on a few of my other columns such as [message-id], [sender-address] etc.

The columns in question are ones which can range from being very small to very large in size, and I have no real control over the size of the columns. These are the columns I am questioning about:

[message-subject] NVARCHAR(MAX)
[recipient-address] NVARCHAR(MAX)

My table name is MessageTracking.

Users will need to be able to query for content potentially in the middle of the strings, and I know that if you use a normal index that you can't do queries like 'WHERE Something LIKE '%SomeValue%' as it won't use any indexes if the WHERE clause is prefixed with %.

I was thinking should I create a FULL TEXT index on these columns? currently my largest data value in the columns is only around 130 characters long but i've seen message-subjects of around 300 characters in length and recipient-address values larger than that.

Need any more info then please ask and I will try and provide info.

Question by:chrismerritt
    LVL 6

    Accepted Solution

    Yes, using a full text index is the right way to go.
    LVL 9

    Author Comment

    Thought so, just wanted to confirm. Seems to be working good so I will close this one off now. Queries coming back nice and fast at the moment :)

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now