mysql - Any better alternative for getting last record without limit -


i have following query

declare lv_duration int;         set @lv_duration = 0;           select @lv_duration := timestampdiff(second,  changedon,now())        `transactionhistory`       transaction_id = trim(_transaction)              order tsh_id desc      limit 1;  

in getting time since last entry of transaction_id fields.but taking .25 of second in relative mid size table.my primary auto-increment field tsh_id. have index on transaction_id field. think ordering , taking last record might have performance impact. alternative it?

from order by optimisation link supplied mcadam331 believe query matches pattern:

  select *      t1    key_part1 = constant order key_part2; 

a composite index on (transaction_id,tsh_id) should speed up.

i don't think there quicker way limit latest record.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -