I use ORDER BY
in the below query but it takes the almost 20 sec to fetch the data.
SELECT id,
name,
o.map.subject,
o.map.xyz
FROM student o
WHERE test = 3553
AND o.map.identifier = 'Abhay'
ORDER BY o.id desc
FETCH first 15 ROWS only;
When do not use ORDER BY
, as shown below, it takes only the 0.2 sec response time which is what I want. The problem is - it is fetching the older data, I need to get the last 15 records inserted into the table student.
Is there any way to sort the data without using ORDER BY
? If not, how can I speed up the query?
SELECT id,
name,
o.map.subject,
o.map.xyz
FROM student o
WHERE test = 3553
AND o.map.identifier = 'Abhay'
FETCH first 15 ROWS only;
SELECT id, name, o.map.subject, o.map.xyz FROM student o WHERE ROWNUM <= 15 AND test = 3553 AND o.map.identifier = 'Abhay' ORDER BY o.id desc;