<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> <font size="-1"><font face="Verdana">I have a piece of code in my page to generate a drop-down listing all of the company''s projects in alphabetical order.<br> <br> <%= select_tag name=''project_name'',options_from_collection_for_select(Project.find(:all, :conditions => "status not containing ''dead''", :order => ''project_name''), "id", "project_name") %><br> <br> When my page was in PHP, in which I ran the search and looped through the results generating option tags, it was much faster than the select_Tag is right now. There are about 1000 projects. In PHP, the page loaded in about half a second, the rails page takes about 4-5 seconds. I tried manually looping and generating option tags instead of using the select_tag method, but it wasn''t much better. Any suggestions?<br> </font></font> </body> </html>
Did you take a look at the logs to see what SQL was being generated, and what percentage of the time it took to create the db request, render the page etc? Try to narrow it down a bit. On 1/9/06, Dylan Markow <dylan@dylanmarkow.com> wrote:> I have a piece of code in my page to generate a drop-down listing all of > the company''s projects in alphabetical order. > > <%= select_tag > name=''project_name'',options_from_collection_for_select(Project.find(:all, > :conditions => "status not containing ''dead''", :order => ''project_name''), > "id", "project_name") %> > > When my page was in PHP, in which I ran the search and looped through the > results generating option tags, it was much faster than the select_Tag is > right now. There are about 1000 projects. In PHP, the page loaded in about > half a second, the rails page takes about 4-5 seconds. I tried manually > looping and generating option tags instead of using the select_tag method, > but it wasn''t much better. Any suggestions? > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- - Nic
98% rendering, 2% database. Rails is running under lighttpd. My PHP version is on the exact same server, running under Apache2. Nic Werner wrote: Did you take a look at the logs to see what SQL was being generated, and what percentage of the time it took to create the db request, render the page etc? Try to narrow it down a bit. On 1/9/06, Dylan Markow wrote: I have a piece of code in my page to generate a drop-down listing all of the company''s projects in alphabetical order. <%= select_tag name=''project_name'',options_from_collection_for_select(Project.find(:all, :conditions => "status not containing ''dead''", :order => ''project_name''), "id", "project_name") %> When my page was in PHP, in which I ran the search and looped through the results generating option tags, it was much faster than the select_Tag is right now. There are about 1000 projects. In PHP, the page loaded in about half a second, the rails page takes about 4-5 seconds. I tried manually looping and generating option tags instead of using the select_tag method, but it wasn''t much better. Any suggestions? _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails -- - Nic _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Also, don''t know if it matters, but I just tried running the site off of apache instead of lighttpd, but the speed is identical. Nic Werner wrote: Did you take a look at the logs to see what SQL was being generated, and what percentage of the time it took to create the db request, render the page etc? Try to narrow it down a bit. On 1/9/06, Dylan Markow wrote: I have a piece of code in my page to generate a drop-down listing all of the company''s projects in alphabetical order. <%= select_tag name=''project_name'',options_from_collection_for_select(Project.find(:all, :conditions => "status not containing ''dead''", :order => ''project_name''), "id", "project_name") %> When my page was in PHP, in which I ran the search and looped through the results generating option tags, it was much faster than the select_Tag is right now. There are about 1000 projects. In PHP, the page loaded in about half a second, the rails page takes about 4-5 seconds. I tried manually looping and generating option tags instead of using the select_tag method, but it wasn''t much better. Any suggestions? _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails -- - Nic _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I haven''t used it yet, but maybe app/script/performance/profiler will help you learn what''s consuming all that time. SteveT On Monday 09 January 2006 01:51 pm, Dylan Markow wrote:> Also, don''t know if it matters, but I just tried running the site off of > apache instead of lighttpd, but the speed is identical. > > Nic Werner wrote: > Did you take a look at the logs to see what SQL was being generated, > and what percentage of the time it took to create the db request, > render the page etc? > > Try to narrow it down a bit. > > On 1/9/06, Dylan Markow <dylan@dylanmarkow.com> wrote: > > > I have a piece of code in my page to generate a drop-down listing all of > the company''s projects in alphabetical order. > > <%= select_tag > name=''project_name'',options_from_collection_for_select(Project.find(:all, > > :conditions => "status not containing ''dead''", :order => ''project_name''), > > "id", "project_name") %> > > When my page was in PHP, in which I ran the search and looped through the > results generating option tags, it was much faster than the select_Tag is > right now. There are about 1000 projects. In PHP, the page loaded in about > half a second, the rails page takes about 4-5 seconds. I tried manually > looping and generating option tags instead of using the select_tag method, > but it wasn''t much better. Any suggestions? > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Dylan Markow wrote:>I have a piece of code in my page to generate a drop-down listing all of the >company''s projects in alphabetical order. > ><%= select_tag >name=''project_name'',options_from_collection_for_select(Project.find(:all, >:conditions => "status not containing ''dead''", :order => ''project_name''), "id", >"project_name") %> > >When my page was in PHP, in which I ran the search and looped through the >results generating option tags, it was much faster than the select_Tag is right >now. There are about 1000 projects. In PHP, the page loaded in about half a >second, the rails page takes about 4-5 seconds. I tried manually looping and >generating option tags instead of using the select_tag method, but it wasn''t >much better. Any suggestions? > >I would suggest you should try adding :select => ''id, project_name'' to your find. This way only the id and project_name will be retrieved in your query, potentially making the instantation of your project records a lot faster. -- stefan -- For rails performance tuning, see: http://railsexpress.de/blog Subscription: http://railsexpress.de/blog/xml/rss20/feed.xml
That fixed the problem perfectly. Weird that i had a full "SELECT *" in PHP and it still went fast. Thanks!! Stefan Kaes wrote: Dylan Markow wrote: I have a piece of code in my page to generate a drop-down listing all of the company''s projects in alphabetical order. <%= select_tag name=''project_name'',options_from_collection_for_select(Project.find(:all, :conditions => "status not containing ''dead''", :order => ''project_name''), "id", "project_name") %> When my page was in PHP, in which I ran the search and looped through the results generating option tags, it was much faster than the select_Tag is right now. There are about 1000 projects. In PHP, the page loaded in about half a second, the rails page takes about 4-5 seconds. I tried manually looping and generating option tags instead of using the select_tag method, but it wasn''t much better. Any suggestions? I would suggest you should try adding :select => ''id, project_name'' to your find. This way only the id and project_name will be retrieved in your query, potentially making the instantation of your project records a lot faster. -- stefan _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
2006/1/12, Dylan Markow <dylan@dylanmarkow.com>:> That fixed the problem perfectly. Weird that i had a full "SELECT *" in PHP > and it still went fast. Thanks!! > >Take a look at your logs, your SELECT might not have been what you expected it to be (perhaps someJoins you didn''t want?) Douglas