[英]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.