---
# System prepended metadata

title: 查詢sql效能

---

查詢SQL查詢的效能
```sql=
/****** SSMS 中 SelectTopNRows 命令的指令碼  ******/

DECLARE @StartTime DATETIME = GETDATE();

--要執行的語法
SELECT TOP (1000) [GUID]
      ,[TargetUrl]
      ,[Request]
      ,[Response]
      ,[CDate]
      ,[Method]
      ,[Status]
      ,[TryCount]
  FROM [euiapp].[dbo].[ApiCache]
  where TargetUrl='GetLoanInRecord'
  and [Request] like '%eneUZAACGide1cQhTB3F%'
  order by cdate desc


DECLARE @EndTime DATETIME = GETDATE();
DECLARE @DurationMilliseconds INT = DATEDIFF(MILLISECOND, @StartTime, @EndTime);

PRINT 'Query execution time: ' + CAST(@DurationMilliseconds AS VARCHAR) + ' milliseconds';
```

:::info
:bulb: 
(247 個資料列受到影響)
Query execution time: 6390 milliseconds
**完成時間**: 2023-08-09T12:51:07.0883727+08:00
:::