Quellcode durchsuchen

Fix slow query

master
Dylan Baker vor 8 Monaten
Ursprung
Commit
e5bc0c6a43
2 geänderte Dateien mit 2 neuen und 3 gelöschten Zeilen
  1. 2
    2
      lib/search.rb
  2. 0
    1
      web/server.rb

+ 2
- 2
lib/search.rb Datei anzeigen

@@ -57,7 +57,7 @@ end
57 57
 def search_threads(q, username, from_date, to_date, sort, offset, exact_match)
58 58
   sort = Sequel.desc(sort == 'post' ? :last_post_created_at : :created_at)
59 59
   query = VLV::Thread
60
-    .select(Sequel.lit('threads.*, count(*) OVER() AS full_count'))
60
+    .select(Sequel.lit('threads.*'))
61 61
     .where(Sequel.lit("(LOWER(threads.creator) = LOWER(?) OR ? = '')", username, username))
62 62
     .where(Sequel.lit("created_at >= ? OR ? IS NULL", from_date, from_date))
63 63
     .where(Sequel.lit("created_at >= ? OR ? IS NULL", to_date, to_date))
@@ -74,7 +74,7 @@ end
74 74
 
75 75
 def search_posts(q, username, from_date, to_date, offset, exact_match)
76 76
   query = VLV::Post
77
-    .select(Sequel.lit('posts.*, threads.title as thread_title, threads.remote_id as remote_thread_id, count(*) OVER() AS full_count'))
77
+    .select(Sequel.lit('posts.*, threads.title as thread_title, threads.remote_id as remote_thread_id'))
78 78
     .join(Sequel.lit('threads on posts.thread_id = threads.id'))
79 79
     .where(Sequel.lit("(LOWER(posts.creator) = LOWER(?) OR (? = ''))", username, username))
80 80
     .where(Sequel.lit("posts.created_at >= ? OR ? IS NULL", from_date, from_date))

+ 0
- 1
web/server.rb Datei anzeigen

@@ -45,7 +45,6 @@ class VLVSearch < Sinatra::Base
45 45
       erb :results, { locals: {errors: results[:errors]}, layout: :layout }
46 46
     else
47 47
       params[:current_count] = results[:results].to_a.size
48
-      params[:full_count] = results[:results].empty? ? 0 : results[:results].first[:full_count]
49 48
       previous_url, next_url = build_urls(params)
50 49
 
51 50
       locals =

Laden…
Abbrechen
Speichern