# Improve performance of Topic load - ORDER BY RANDOM

**URL:** https://meta.discourse.org/t/improve-performance-of-topic-load-order-by-random/25619
**Category:** Bug
**Tags:** slow-sql
**Created:** [2월 24, 2015, 4:48오후 UTC](https://meta.discourse.org/t/improve-performance-of-topic-load-order-by-random/25619 "2015-02-24T16:48:29Z")
**Posts on this page:** 4
**Page:** 2

<div class="post-metadata">

### Author: ![lightyear](https://avatars.discourse-cdn.com/v4/letter/l/848f3c/32.png) [@lightyear](https://meta.discourse.org/u/lightyear)
#### Post date: [2월 28, 2015, 9:13오후 UTC](https://meta.discourse.org/t/improve-performance-of-topic-load-order-by-random/25619/21 "2015-02-28T21:13:22Z")

</div>

Didn’t know this was still an issue on vanilla. We dropped the random in the [database entirely as described here](https://meta.discourse.org/t/slow-sql-queries/16604/43) and where able to drop the execute to less than 50ms for suggested topics even with more than a million topics…

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [3월 1, 2015, 10:50오후 UTC](https://meta.discourse.org/t/improve-performance-of-topic-load-order-by-random/25619/22 "2015-03-01T22:50:12Z")

</div>

This is totally unneeded now as the optimisations I made nullify needing this change.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [3월 1, 2015, 10:52오후 UTC](https://meta.discourse.org/t/improve-performance-of-topic-load-order-by-random/25619/23 "2015-03-01T22:52:10Z")

</div>

I can see why created\_at is needed there, its the query that is trying to find new topics it takes into account a “start date”.

Added the index and can confirm perf is way better:

[https://github.com/discourse/discourse/commit/20bee937b70e04aa5afb09635b8aa85866dee588](https://github.com/discourse/discourse/commit/20bee937b70e04aa5afb09635b8aa85866dee588)

Thanks for your help here @DeanMarkTaylor !!! closing this for now I feel it has been fully addressed 🙂

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [3월 1, 2015, 10:52오후 UTC](https://meta.discourse.org/t/improve-performance-of-topic-load-order-by-random/25619/24 "2015-03-01T22:52:15Z")

</div>



[이전 페이지](https://meta.discourse.org/t/improve-performance-of-topic-load-order-by-random/25619.md?page=1)
