db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <rick.hille...@gmail.com>
Subject Re: Using indexes
Date Sat, 25 Sep 2021 18:14:29 GMT
On 9/25/21 7:39 AM, John English wrote:
> SELECT id,DateTimeFormat(time,null) AS 
> t_time,name,username,facility,event,details
> FROM system_log
> ORDER BY id DESC
> NULLS LAST
> FETCH FIRST 20 ROWS ONLY;

I can remember whether you tried to rewrite the query to use a subquery. 
Something like this:

SELECT id, time AS t_time,name,username,facility,event,details
FROM
   system_log s,
   (
     SELECT id AS log_id
     FROM system_log
     ORDER BY id DESC
     NULLS LAST
     FETCH FIRST 20 ROWS ONLY
   ) t
WHERE s.id = t.log_id
;

Does that help?

-Rick


Mime
View raw message