vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   29 queries on Forumhome !!! (https://vborg.vbsupport.ru/showthread.php?t=38471)

Admin 05-19-2002 01:48 PM

Send me your index.php by email and I'll take a look. You must have a query inside a loop which is how you get to 40.

Jawelin 05-20-2002 07:59 AM

It's comin'... Actually I don't think there's any recursive or iterative call... but I'm sending it to you.

LMK

Thanks a lot.
Bye

Erwin 05-20-2002 11:52 AM

Thanks for the $templatesused hint - saved me quite a few queries on my index, forumdisplay and showthread! :)

MattR 05-26-2002 01:46 AM

You can tie the 3 PM queries into one if you're good. :D

Admin 05-26-2002 10:18 AM

I did that Matt. :)

PHP Code:

  $allpm=$DB_site->query_first("SELECT COUNT(*) AS messages,
                                SUM(IF(dateline>
$bbuserinfo[lastvisit] AND folderid=0,1,0)) AS newpm,
                                SUM(IF(messageread=0 AND folderid=0,1,0)) AS unreadpm
                                FROM privatemessage WHERE userid=
$bbuserinfo[userid] $ignoreusers");

  
$newpm['messages']=$allpm['newpm'];
  
$unreadpm['messages']=$allpm['unreadpm']; 

Well I copied it from somewhere, don't really remember right now. But the problem is the query is slower for users with lots and lots of PM's (like myself), but considering most people don't I thought it would be wiser to just use that one query.

Erwin 05-26-2002 02:02 PM

You're right - I reduced my index.php queries from 52 to 33 using all the stuff I learnt from here, WITHOUT reducing the number of hacks I have. ;)

MattR 05-26-2002 02:57 PM

Quote:

Originally posted by FireFly
Well I copied it from somewhere, don't really remember right now. But the problem is the query is slower for users with lots and lots of PM's (like myself), but considering most people don't I thought it would be wiser to just use that one query.
I think I suggested something like that on the vB Dev forum. At least with Sybase it is significantly faster than the 3 queries and with less I/O.

FWC 05-26-2002 06:51 PM

Quote:

Originally posted by FireFly
Well I copied it from somewhere, don't really remember right now.
I just copied it from here. Thanks, Chen! :)

Admin 05-27-2002 10:59 AM

Thank Matt. :)

Jawelin 05-27-2002 01:59 PM

I suddendly grabbed your precious trick !
:D

Well; I would use the same SUM(IF()) or COUNT(IF()) constructs on tables like post or thread, to reduce the query count when I check for posts since a time, per user, and so on...
(note: I built indexes on those 'time' fields)

My question is: should a COUNT(IF()) clause much heavy than three or forur different SELECTS, on such a large tables ?

Thanks


All times are GMT. The time now is 01:46 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.01145 seconds
  • Memory Usage 1,738KB
  • 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_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)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