Answer the question
In order to leave comments, you need to log in
Clustered or non-clustered index?
It's about Microsoft SQL Server. There is a table with login logs:
[time] [datetime] NOT NULL,
[account] [varchar](14) NOT NULL,
[
ip] [varchar](15) NOT NULL
binary format for ip). The selection by the account field is often used, so I want to add an index. What type of index is better to use in this case? Clustered or non-clustered?
Answer the question
In order to leave comments, you need to log in
For sure, selection by account is done with sorting by time and cut-off by time, either by top or by time range. In this case, I think, a composite index on a pair (account, time) will be appropriate.
Here is a clustered one - whether I doubt it. Do you need that much additional five kopecks for selection so that you can sacrifice a little performance on the insert? I guess it's unlikely. Insertion speed, I think, will be very critical here.
>> Is it worth it in this case to make the index composite and clustered?
A composite index for a pair (time, account), for selection by account, will probably be useless to you. And for selection by account and time range (or sorted by time and cut off by top / time value), it will be significantly less effective than by the pair (account, time)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question