Admin Forum:Switch parser functions

Forums: Admin Central Index → Technical Help → Switch parser functions Wikia's forums are a place for the community to help other members. To contact staff directly or to report bugs, please use Special:Contact.

Hi, I'm setting up templates for particular stats on F1 Wiki using a switch template. The idea is to fill the templates with stats for all the drivers, so that an infobox will return the correct value based on the page name (see here for example and here for its usage). The system works in small numbers (up to about 100) but I'd like some advice:
 * Is there a maximum number of options that can be used?
 * Is it going to slow down the page loading?

Thanks

MTracey1 PSN/XBL: Mackem1985 18:22, May 2, 2012 (UTC)
 * Hey, I checked the related documentation on https://www.mediawiki.org/ and did not find any reference to a case limit, so it theoretically supports any number of parameters. As for the loading time impact, there's no data, but whatever it outputs is calculated before the PHP page is served to the browser as (X)HTML&mdash;server–side scripting&mdash;therefore any delays would simply extend the length of the blank loading screen and would not result in partial loads. 09:31, May 7, 2012 (UTC)


 * Oh, there's plenty of data that really huge numbers of #switch cases slow things down. What's maybe less certain is the precise number at which things slow down to unacceptable levels. But the best wiki coding minds on the planet do seem to agree that if you've got a #switch with thousands of cases, you're probably getting out of control.


 * You really should ask your question of user:Tim Starling. He's essentially the author/maintainer of the ParserFunctions Extension — that is, the section of the code that enables #switch.  As of 30 January 2012, he was indicating that he was contemplating installing an upper limit of "2000 or so" switch cases per article — at least on the version used by Wikipedia — because some people were really overusing the function.  When you start using thousands upon thousands of different cases, it, according to him "uses hundreds of megabytes of unaccounted memory and can even send the servers into swap". He seems to be moving toward the notion that limiting #switch might be necessary to protect servers.


 * I'd advise that you consider other alternatives for doing what you want to do. You might look into Semantic MediaWiki as a possible alternative for achieving what you want.  13:46: Sat 12 May 2012
 * Yeah, looking at what you're trying to do, I definitely think you want the SMW option. You're trying to create a database with #switch, and that's not a recommended use of that parser function.  Instead of assigning a number of wins by #switch, you'd assign a number of wins by adding something like this to a driver's page: wins::12


 * That would then assign a value of 12 to the property "wins" on the page w:c:f1:Alan Jones. You could then manipulate that number in a variety of ways.  SMW was essentially made for sports wikis.  I mean, it would obsolete the entirety of w:c:f1:category:Subtemplates of Template:Stats.


 * SMW is not enabled by default on any wiki, but Staff will do it for you through Special:Contact. However, you need to have read up on it and have a clear sense of how you're going to use it.  The best place to go for that is, naturally enough, the manual.  You can find it at http://semantic-mediawiki.org/wiki/Help:User_manual.  Also, you may wanna send a note to User:DaNASCAT, who is one of the staff members with a lot of experience with it.  He might be able to offer you some additional resources. But I'm tellin' ya: I've never seen a clearer need for SMW than your wiki.   14:01: Sat 12 May 2012

Thanks for your advice. I'll take a look at that when I get the time, and probably go down that route. MTracey1 PSN/XBL: Mackem1985 14:11, May 12, 2012 (UTC)