SQL query executing slowly (for some parameter values)
问题 I have a SQL Server 2005 database with several tables. One of the tables is used to store timestamps and message counters for several devices, and has the following columns: CREATE TABLE [dbo].[Timestamps] ( [Id] [uniqueidentifier] NOT NULL, [MessageCounter] [bigint] NULL, [TimeReceived] [bigint] NULL, [DeviceTime] [bigint] NULL, [DeviceId] [int] NULL ) Id is the unique primary key (Guid.Comb), and I have indexes on both DeviceId and MessageCounter columns. What I want to do is find the last