<p>I ask this question a few weeks ago, but could not fix this problem. Now i have minimize my code.
i use this loop: </p>

<p><code>{% for program in craft.entries.section('program_point').order('program_number') %}</code></p>

<p>and it takes 25s. The loop returns 81 data.</p>

<p>Is there a way to speed this up?</p>

CC BY-SA 3.0
2015-08-31T19:15:54.520Z
If you enable [devMode](http://buildwithcraft.com/docs/config-settings#devMode) and load the page with that loop, then check in your browser's console, you'll see in the profiling section all of the database queries that are ordered by slowest performing at the top. Is there one that is taking 20+ seconds to execute?
Brad Bell
CC BY-SA 3.0
2015-09-01T16:13:47.470Z
@BradBell the number ad total shows the performing? The biggest is 0.05
Jonathan Schiffner
CC BY-SA 3.0
2015-09-01T17:16:33.213Z
Are there 500+ queries each taking up that amount of time?
Brad Bell
CC BY-SA 3.0
2015-09-01T18:05:12.860Z
@BradBell No there are 232 queries and most of them taking about 0.005
Jonathan Schiffner
CC BY-SA 3.0
2015-09-01T19:55:32.823Z
I don't think the line of code you shared is the problem, then. Look at the timestamps for the logs in `craft/storage/runtime/logs` for that request and see if you can spot the delay.
Brad Bell
CC BY-SA 3.0
2015-09-02T10:34:51.173Z
But if i delete this loop, the page loads in normal time. And in the logs i can't find anything about this problem.
Jonathan Schiffner
CC BY-SA 3.0
2015-09-02T15:41:02.193Z
What if you leave the loop in but remove all if it's contents (everything between `{% for %}` and `{% endfor %}`?
Brad Bell
CC BY-SA 3.0
2015-09-02T19:56:01.063Z
Now the loop takes about 6s. I think this is also to long.
Here is the link of the site with the whole loop: [http://www.christlicher-gesundheitskongress.de/program.html] Maybe this gives you an idea...
And here is the code: [https://jsfiddle.net/zkn1b8s2/]
Jonathan Schiffner
CC BY-SA 3.0
2015-09-02T20:45:50.237Z
Can you enable devMode on that site for a bit?
Brad Bell
CC BY-SA 3.0
2015-09-02T21:19:39.313Z
Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/27701/discussion-between-jonathan-schiffner-and-brad-bell).
Jonathan Schiffner
CC BY-SA 3.0
2015-09-02T21:24:37.120Z
Did you try caching the the output, as I mentioned in my answer here? I assume this is also you, as a different username: http://craftcms.stackexchange.com/questions/11161/server-respond-is-very-long-25s-is-there-a-way-to-optimize-the-perfomance
RitterKnight
CC BY-SA 3.0
2015-09-03T18:36:37.820Z
thanks i did not now, that my colleague post this question too. Sorry!
Jonathan Schiffner
<templating><performance>
25s TTFB for one for-loop
# 25s TTFB for one for-loop

(Asked by: username_0 on 2015-08-31)

I ask this question a few weeks ago, but could not fix this problem. Now i have minimize my code.
i use this loop:

`{% for program in craft.entries.section('program_point').order('program_number') %}`

and it takes 25s. The loop returns 81 data.

Is there a way to speed this up?

**Tags:** templating, performance

> **Comments:**
> **username_1**: If you enable [devMode](http://buildwithcraft.com/docs/config-settings#devMode) and load the page with that loop, then check in your browser's console, you'll see in the profiling section all of the database queries that are ordered by slowest performing at the top. Is there one that is taking 20+ seconds to execute?  
> **username_0**: @BradBell the number ad total shows the performing? The biggest is 0.05  
> **username_1**: Are there 500+ queries each taking up that amount of time?  
> **username_0**: @BradBell No there are 232 queries and most of them taking about 0.005  
> **username_1**: I don't think the line of code you shared is the problem, then. Look at the timestamps for the logs in `craft/storage/runtime/logs` for that request and see if you can spot the delay.  
> **username_0**: But if i delete this loop, the page loads in normal time. And in the logs i can't find anything about this problem.  
> **username_1**: What if you leave the loop in but remove all if it's contents (everything between `{% for %}` and `{% endfor %}`?  
> **username_0**: Now the loop takes about 6s. I think this is also to long. Here is the link of the site with the whole loop: [http://www.christlicher-gesundheitskongress.de/program.html] Maybe this gives you an idea... And here is the code: [https://jsfiddle.net/zkn1b8s2/]  
> **username_1**: Can you enable devMode on that site for a bit?  
> **username_0**: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/27701/discussion-between-jonathan-schiffner-and-brad-bell).  
> **username_2**: Did you try caching the the output, as I mentioned in my answer here? I assume this is also you, as a different username: http://craftcms.stackexchange.com/questions/11161/server-respond-is-very-long-25s-is-there-a-way-to-optimize-the-perfomance  
> **username_0**: thanks i did not now, that my colleague post this question too. Sorry!  

---

## 0 answers

