From 9b1b6be3719edfe165d5ae1fce502bc6ffb5de24 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 12 Dec 2008 15:17:14 +0000 Subject: [PATCH] Optimise lookup of traces with a given tag. --- app/controllers/trace_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index 91ae92b05..bcac11844 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -48,8 +48,9 @@ class TraceController < ApplicationController if params[:tag] @tag = params[:tag] - conditions[0] += " AND EXISTS (SELECT * FROM gpx_file_tags AS gft WHERE gft.gpx_id = gpx_files.id AND gft.tag = ?)" - conditions << @tag + + files = Tracetag.find_all_by_tag(params[:tag]).collect { |tt| tt.gpx_id } + conditions[0] += " AND gpx_files.id IN (#{files.join(',')})" end conditions[0] += " AND gpx_files.visible = 1" -- 2.39.5