I have something like
SELECT var1,var2 FROM table where var3=X AND var4=Y order by var5 desc limit 1;
Running this query takes roughly 5 seconds on my database which is far to slow. I was wondering if there was any way to retrieve the last row in a way similar to this
SELECT var1,var2 FROM table where var3=X AND var4=Y limit 1;
bcause that is almost instant (.03 seconds) on my database. So, if there was some way to have a query print everything in reverse order that would solve every issue I am having. I have been searching for a long while now and every answer seems to be with using ORDER BY
or subqueries which are all >= 5 seconds.
EDIT The tables are not indexed.
order by
.rowID
that has these (1,2,3) values stored. If you meant "last as ordered byval5
", that's fine. But it wasn't obvious in your comment.