[英]Querying and sorting a big table in Oracle 12c
假設我有一個個人數據表Table1
: first_name
, last_name
, date_of_birth
, address
。 數百萬行。 我應該創建什么索引才能在以下查詢中快速運行:
select * from Table1 where date_of_birth > some_date and contains(address,'some street') > 0 order by first_name offset 100 rows fetch next 5 rows only;
select * from Table1 where date_of_birth > some_date and contains(address,'some street') > 0 order by last_name offset 100 rows fetch next 5 rows;
這是一個簡化的案例,但是我想弄清楚的是如何為類似於ebay的網站構建數據庫結構,即幾個排序順序,幾個數字參數和文本描述。 我已經在address
上有文本索引
索引是否有用取決於各種條件。
date_of_birth
范圍) date_of_birth > 1900-01-01
選擇) 在某些情況下,全表掃描是更好的選擇。
要決定這一點,您必須研究表的數據,檢查業務案例,調查執行計划
在某些情況下,您可以改善選擇語句。
例如
使用上限限制date_of_birth的范圍。
where date_of_birth between some_date and some_date +7
這與您的select語句不同(僅在此范圍內按名稱排序),但可能足夠好,可以顯着提高性能
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.