vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Unnecessary query? (https://vborg.vbsupport.ru/showthread.php?t=60965)

Andreas 01-30-2004 03:24 PM

Unnecessary query?
 
In global.php
$show['modcplink'] is being set (for the ModCP-Link in template footer).

This seems to trigger a query in can_moderate() if the user is not an admin or supermod - for every page being generated.

I wonder if it wouldn't be possible to use some cache (datastore) instead to avoid this query and if this could improve performance?

Xenon 01-31-2004 12:06 AM

the first if does just use the permission cache, so no query is done until:
PHP Code:

if ($forumid == 0

then as forumid is 0 on that position, it's going through the modcache itself and looking if the user is in so, no query is done there either, just if the cache has not been created, it will do a query.

Andreas 01-31-2004 12:49 AM

> just if the cache has not been created, it will do a query.
That's the point.

$imodcache is being build in cache_moderators() which itself gets called from forumdisplay.php, index.php, search.php & usercp.php - after processing global.php.

And what about the others like showthread.php, newreply.php and so on?

NTLDR 01-31-2004 07:00 PM

Seeing as cache_moderators() requires a query and so does can_moderate() using can_moderate() would be prefered as its doing less work. It does seem that in my RC3 copy that they have 'forgotten/not included yet' the caching in the can_moderate() function, the $modcache variable is there, yet its never set, which causes extra queries every time can_moderate() is called where it could quite possibly return a cached value instead.

Andreas 02-10-2004 07:46 PM

*bump*
Now that RC4 is available it seems like this doesn't have changed :(

Example
-----------
If a thread is being displayed (by a normal user, 40 posts/page) and can_moderate() is being called from the postbit I get 42 (!) times the same query:

Code:

SELECT moderatorid, permissions FROM moderator WHERE userid = 3
So once again, is that necessary? ;)

Zachery 02-10-2004 07:50 PM

ugh you querry freaks :P

NTLDR 02-10-2004 07:53 PM

So you have 42+ queries on that page? Thats not good. I'm sure some caching is ment to be used in the function, create a bug report at vB.com.

Zachery 02-10-2004 08:00 PM

Quote:

Originally Posted by NTLDR
So you have 42+ queries on that page? Thats not good. I'm sure some caching is ment to be used in the function, create a bug report at vB.com.

Whoa... ive never seen more than 12 querrys on any page in vB3 >.< (cept admincp)

Andreas 02-10-2004 08:07 PM

@Faranth
It's very easy to reproduce:

1) Take a vanilla vB3 RCwhatever
2) Enable debug mode (to see # of queries)
3) Put an <if condition="can_moderate()"></if> at the start of template postbit
4) Display a thread with > 40 posts as a normal user (setting display-mode to 40 posts/page)

Xenon 02-10-2004 09:52 PM

you should definitely report it.

vb.com will surely look into it :)


All times are GMT. The time now is 07:13 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01446 seconds
  • Memory Usage 1,729KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete