# Permalink overhead

**URL:** https://meta.discourse.org/t/permalink-overhead/51558
**Category:** Development
**Created:** [October 14, 2016, 4:57pm UTC](https://meta.discourse.org/t/permalink-overhead/51558 "2016-10-14T16:57:40Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 14, 2016, 4:57pm UTC](https://meta.discourse.org/t/permalink-overhead/51558/1 "2016-10-14T16:57:40Z")

</div>

I’m updating `bbpress.rb` to have it deal with attachments (now it inserts a link to the attachment on the original site) and create permalinks for the old URLs.

The old format is `/forums/topic/slug’. For anyone who knows how to write an Nginx redirect, it’s pretty simple to redirect that to /t/slug and be done with it. OTOH at this particular instant, it is faster for me to add code to the importer to create those permalinks.

Question: Is there any reason **not** to create a permalink for every topic?

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [October 14, 2016, 5:13pm UTC](https://meta.discourse.org/t/permalink-overhead/51558/2 "2016-10-14T17:13:15Z")

</div>

There is an option already.

> [@Redirect old forum URLs to new Discourse URLs using permalinks](https://meta.discourse.org/t/redirecting-old-forum-urls-to-new-discourse-urls/20930):
>
> Redirecting Old Forum URLs to New Discourse URLs using permalinks If you’ve moved from other forum software to Discourse using [one of our import scripts](https://github.com/discourse/discourse/tree/main/script/import_scripts), then you probably want all your hard-earned Google search results to continue pointing to the same content. Discourse has a built-in way to handle this for you as an alternative to writing nginx rules, using the permalinks lookup table. The permalinks table allows you to set two things: a url to match, and what that url should show. There a…

Are you looking for something else?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 14, 2016, 5:18pm UTC](https://meta.discourse.org/t/permalink-overhead/51558/3 "2016-10-14T17:18:11Z")

</div>

> [@vinothkannans](#):
>
> Are you looking for something else?

No, that’s what I’m doing, though rather than having to enter the rails console and find a way to do a `Permalink.create` for every URL, I’m doing that automatically in the importer. Normal People should not be subjected to the Rails console. 🙂

My current hypothesis is that it might actually be (a very tiny bit) better to have Discourse do the redirects than to get Nginx to do it, as adding that redirect will cause Nginx to have to process it on every url request.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 14, 2016, 5:19pm UTC](https://meta.discourse.org/t/permalink-overhead/51558/4 "2016-10-14T17:19:49Z")

</div>

> [@pfaffman](#):
>
> better to have Discourse do the redirects than to get Nginx to do it, as adding that redirect will cause Nginx to have to process it on every url request.

Actually, doing it on Nginx should be way faster than doing in Discourse. The problem is that Discourse is **way** easier, friendly and portable, while Nginx should be treated in a case-by-case basis.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 14, 2016, 5:22pm UTC](https://meta.discourse.org/t/permalink-overhead/51558/5 "2016-10-14T17:22:37Z")

</div>

Thanks, @falco. I’ll take that as a “no.” There’s no reason not to have the importer add a redirect for every topic, and no reason to make it easy to turn off that functionality (e.g., by setting an environment variable).

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [October 14, 2016, 5:23pm UTC](https://meta.discourse.org/t/permalink-overhead/51558/6 "2016-10-14T17:23:58Z")

</div>

in phpbb3 importer script they already using it

> <https://github.com/discourse/discourse/blob/main/script/import_scripts/phpbb3/importers/permalink_importer.rb#L32>

Hope it can help you 🙂

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 14, 2016, 5:25pm UTC](https://meta.discourse.org/t/permalink-overhead/51558/7 "2016-10-14T17:25:09Z")

</div>

Maybe having an easy turn off is a good thing. If I were doing a special custom import, I would prefer the nginx redirect route.

But having the code in a reusable script that doesn’t make me do it every time is very valuable.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 14, 2016, 5:27pm UTC](https://meta.discourse.org/t/permalink-overhead/51558/8 "2016-10-14T17:27:01Z")

</div>

> [@Falco](#):
>
> One to turn it all off (default on) looks good for me.

Done. But, if it’s you that we’re talking about, you can just put a `#` in the front of the `create_permalinks` call in `execute`. 🙂

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 14, 2016, 5:27pm UTC](https://meta.discourse.org/t/permalink-overhead/51558/9 "2016-10-14T17:27:48Z")

</div>

One to turn it all off (default on) looks good for me.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 15, 2016, 5:12pm UTC](https://meta.discourse.org/t/permalink-overhead/51558/10 "2016-10-15T17:12:43Z")

</div>

[https://github.com/discourse/discourse/pull/4501](https://github.com/discourse/discourse/pull/4501)

---

<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: [October 17, 2016, 1:13am UTC](https://meta.discourse.org/t/permalink-overhead/51558/11 "2016-10-17T01:13:56Z")

</div>

> [@pfaffman](#):
>
> Is there any reason not to create a permalink for every topic

Nope, I can not think of any performance reasons to avoid permalink creation, it does an indexed lookup which is very cheap.
