Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2012-04-19 20:25:31
- mmelon
- Member
- Registered: 2006-03-02
- Posts: 95
performance of a form to call in place of txp:permlink
Hi
I’ve recently hacked together a local txp setup that lets me nest articles in x levels of pseudo nested sections. I might detail this in the future but it is probably too specific to my own requirements to be useful to anyone else.
The reason for my post is i require that my article permlinks be conditionally altered to sometimes point to the level above the permlink.
If /about-us/why-we-are-awesome is the first article in the about-us category, i would like to amend all permlinks to it to target /about-us.
I know how to do it but i am concerned about performance. I am using smd_wrap to pass the permlink through a transform form to do the logic and conditionally amend the permlink.
The problem is finding the oldest article id requires at least 1 extra sql query per link output – article custom sorted by posted asc, limit 1. Doing this for loads of links seems like a huge resource waste.
Then i thought, does it even matter if wrap the article custom db query in an aks_cache of say 2hrs or even a day? Id be interested to hear what people have to say.
Thinking about it further, i have decided that this logic doesn’t belong in the permlink generating form at all, but rather to be done at the point of editing and saving the article in the admin.
If i could somehow save a custom field value of true, in a field called oldest at the point of saving the article, then i would only have to test against the custom field value in the permlink form, and save all the sql queries.
Sorry for the long post and even more so for composing on my mobile, but i am very curious if and how this can best be tackled.
Thanks for reading
Mike
Offline
Re: performance of a form to call in place of txp:permlink
mmelon wrote:
The problem is finding the oldest article id requires at least 1 extra sql query per link output – article custom sorted by posted asc, limit 1. Doing this for loads of links seems like a huge resource waste.
Then i thought, does it even matter if wrap the article custom db query in an aks_cache of say 2hrs or even a day? Id be interested to hear what people have to say.
aks_cache stores cached content in the database as well, so that’s at least one query to retrieve it. Using article_custom, with a bit of luck the query result is cached by MySQL, so it’ll be blazing fast if you have to execute it multiple times. And you could even optimize it a bit by not using article_custom, but something that allows you to do a simpler query, perhaps using a plugin like smd_query… although bear in mind that loading that plugin adds an extra query AND execution time. It could be done with a block of <txp:php> as well.
Don’t optimize prematurely ;)
Offline
#3 2012-04-20 06:02:09
- mmelon
- Member
- Registered: 2006-03-02
- Posts: 95
Re: performance of a form to call in place of txp:permlink
Cool. Thanks for the reply.
I will try it and see
Offline