作者:手机用户2502934025_218 | 来源:互联网 | 2023-09-16 16:20
Ihaveaquerywhichfetchesthelast30rowsfromthewholetablewhichcontainsthousandsofentri
I have a query which fetches the last 30 rows from the whole table which contains thousands of entries.The table is large so database query is taking more than 5 minutes to execute. How can I avoid the full table scan on the table so that it scans only the last few rows. I am using Oracle 11g
我有一个查询从整个表中获取最后30行,其中包含数千个条目。表很大,因此数据库查询执行时间超过5分钟。如何避免对表进行全表扫描,以便仅扫描最后几行。我正在使用Oracle 11g
SELECT DD,MODEL,CNT,SYS
FROM DVCE_TAB
WHERE DD >= TO_DATE('2015-08-09','YYYY-MM-DD')
AND DD <= TO_DATE('2015-09-08','YYYY-MM-DD')
AND SYS IN ('00','01')
DD is the date and SYS is System type of device and MODEL is name of device DD and MODEL is the combined primary key for the Table TABLE contains thousands of entries and has data from 2010 I have to just fetch last months data
DD是日期,SYS是系统类型的设备,MODEL是设备DD的名称,MODEL是表的组合主键表包含数千个条目,并且有来自2010的数据我只需要获取上个月的数据
1 个解决方案