Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2015-08-19 12:31:47

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: Option prefetch_forms() - preload all forms in a single query

ruud wrote #294220:

Back to prefetching… wouldn’t a aks_prefetch plugin be the optimal solution? That would give the configurability you propose and even allow users to do this per page instead of site-wide.

Now I also think that the best would be a plugin.
But I can not access the static variable $forms.
Another possible way is to add a callback forms.prefetch

If this opportunity to implement a plugin, I do not want to be limited to table txp_form. Why not?
The next possible step: We can store the form in the file system, or use virtual forms within their own plugins. Updated plugin and all plugin virtual forms also “update”. Now I have to update plugins with the update and forms.


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#26 2015-08-29 15:05:24

ruud
Developer emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Option prefetch_forms() - preload all forms in a single query

makks, I think you can do it without directly accessing the static $forms variable if you hook into the form.fetch callback event. You could pull the form content from wherever you want… I’m checking to see if I can make a plugin that does this.

Offline

#27 2015-08-29 17:56:49

ruud
Developer emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Option prefetch_forms() - preload all forms in a single query

NOTE: this plugin requires TXP 4.6

Does anyone want to try?

Those who try, let us know:
  • the number of form queries
  • runtime before you used this plugin
  • runtime after you used this plugin
  • query time before you used this plugin
  • query time after you used this plugin.
  • if you’re prefetching all forms (even the ones not used on that page) or just a select few.
# rvm_prefetch v0.1
# Prefetch forms, reducing the number of SQL queries
# Ruud van Melick
# http://vanmelick.com/txp/

# ......................................................................
# This is a plugin for Textpattern - http://textpattern.com/
# To install: textpattern > admin > plugins
# Paste the following text into the 'Install plugin' box:
# ......................................................................

H4sIAAAAAAAAA41VyW7jRhA9j76ihhBMKmBILbZsUEuQwwQYIIvj0SHBxBBaZFHsMcmme7FG
GPjfU91NKcqG5CCrl1evXr2qlll2l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RiF6W/qq5g+aRgHYRwGMWjJG881shWPAqtxKG2TnHFSHNSW2ie1
dy8G14Y/e+hVeYX0bGuMhhRHFC0V+iAOtFXnxpxMIsSpp4/WVLd3DXr0Pr0O+v+jTXHjVvQC
ptN8nJc4Z7PZrGBY7PKb8e18Ptshu96N7+6Cxevv8TJEno4HAAA=

Offline

#28 2015-08-30 21:02:35

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,212
Website

Re: Option prefetch_forms() - preload all forms in a single query

On a site with an assload of forms.

Before:

<!-- Runtime:    0.3576 -->
<!-- Query time: 0.159883 -->
<!-- Queries: 170 -->
<!-- Memory: 7684Kb, end of textpattern() -->

After:

<!-- Runtime:    0.3738 -->
<!-- Query time: 0.163590 -->
<!-- Queries: 152 -->
<!-- Memory: 7771Kb, end of textpattern() -->

Offline

#29 2015-08-30 21:08:00

ruud
Developer emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Option prefetch_forms() - preload all forms in a single query

So apart from the reduction in queries, everything else got worse. Oops.

Offline

#30 2015-08-30 21:17:58

etc
Developer
Registered: 2010-11-11
Posts: 4,188
Website

Re: Option prefetch_forms() - preload all forms in a single query

The results are fluctuating, but there seems to be about 3% acceleration (0.087 -> 0.085 overall runtime) on a ~vanilla site on my wamp laptop with query cache enabled.

Offline

Board footer

Powered by FluxBB