From 9560c1f8bd8bda1a5d3b8d919b8265c1189d4b1b Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Fri, 7 May 2021 18:03:03 -0400 Subject: Order by rowids for scoop -l This vastly improves the speed of the query, with the same effect as the change to litterbox's query interface. --- scoop.1 | 4 ++-- scoop.c | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/scoop.1 b/scoop.1 index 693c033..480e8be 100644 --- a/scoop.1 +++ b/scoop.1 @@ -1,4 +1,4 @@ -.Dd April 28, 2021 +.Dd May 7, 2021 .Dt SCOOP 1 .Os . @@ -148,7 +148,7 @@ Match events from users with the hostname . .It Fl l Ar limit Limit the number of events matched, -ordered by most recent. +ordered by most recently inserted. Implies .Fl s . . diff --git a/scoop.c b/scoop.c index f1c0ed2..241c566 100644 --- a/scoop.c +++ b/scoop.c @@ -510,7 +510,11 @@ int main(int argc, char *argv[]) { } if (limit) { - append(where, SQL(ORDER BY time DESC, event DESC LIMIT :limit)); + if (optind < argc) { + append(where, SQL(ORDER BY search.rowid DESC LIMIT :limit)); + } else { + append(where, SQL(ORDER BY event DESC LIMIT :limit)); + } binds[n++] = Bind(":limit", limit, 0); } -- cgit 1.4.1