sql查詢語句速度

2021-07-28 12:35:19 字數 858 閱讀 2484

查詢一張百萬資料量的資料庫表,已經建立了索引 flowno。

因為匯出日誌備份需要,要求根據flowno的值取出資料。

即,select部分的語句如下:

對比了以下三種where查詢子句的執行速度:1.

where t.flowno between '2017031400' and '2017031410'

查詢105412條資料耗時126.031秒

where t.flowno between '2017031400' and '2017031401'

查詢4222條資料耗時5.438秒 2.

where t.flowno like '201703140%'

查詢105412條資料耗時124.437秒

where t.flowno like '2017031400%'

查詢4222條資料耗時5.39秒 3.

where t.flowno >='2017031400' and t.flowno <'2017031410'

查詢105412條資料耗時124.078秒

where t.flowno >='2017031400' and t.flowno <'2017031401'

查詢4222條資料耗時4.625秒

從這裡來看,使用直接的大小比較的語句查詢速度要略快一些。

此外,在select子句中使用的拼接也拖慢了系統查詢的速度,這裡要考慮一下要如何優化查詢

sql 語句 查詢

例11 1 1 use xk gocreate trigger test1 on student for update as print 記錄已修改!go 2 update student set pwd 11111111 where stuno 00000001 例11 3 1 use xk go...

SQL查詢語句

create or replace procedure imms pk reportsend fromdate varchar2,todate varchar2 as function 系統效能統計 author qja 功能 將imms statusreport 表和imms report sen...

sql查詢語句

條件查詢 select 列名列表 from 表名 where 條件 where 條件 用來篩選滿足條件的記錄 行 條件有6種形式 1.比較大小 列名 比較運算子 值 查詢圖書 超過30元的圖書資訊 select from book where price 30 查詢清華大學出版社出版的圖書資訊 se...