SQL order by ID desc/asc加一个排序的字段解决查询慢问题
解决方法就是在order by ID desc再加一个排序的字段,这样子可能会把速度提高很多。再加止排序的字段因查询而异了
如表
<div class="codetitle"><a style="CURSOR: pointer" data="89690" class="copybut" id="copybut89690" onclick="doCopy('code89690')"> 代码如下:
<div class="codebody" id="code89690">
CREATE TABLE [dbo].[CMPP_SendCentre] (
[id] [int] IDENTITY (1,1) NOT NULL,
[SendType] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL,
[SendDate] [datetime] NOT NULL,
[Port] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL,
[Service_ID] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL,
[FeeType] [varchar] (2) COLLATE Chinese_PRC_CI_AS NOT NULL,
[FeeCode] [varchar] (6) COLLATE Chinese_PRC_CI_AS NOT NULL,
[Msg_Content] [varchar] (1024) COLLATE Chinese_PRC_CI_AS NOT NULL,
[SendCount] [int] NOT NULL,
[SucceedCount] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[CMPP_SendCentreMo] (
[id] [int] IDENTITY (1,
[SendCentreID] [int] NOT NULL,
[Mo] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL,
[Stat] [varchar] (10) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
CMPP_SendCentreMo.SendCentreID 与CMPP_SendCentre.ID成外建关系