vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   top10stats in 1 query? (https://vborg.vbsupport.ru/showthread.php?t=91120)

HakkieDEV 06-26-2005 04:30 PM

top10stats in 1 query?
 
Hi all,

I've some top10 statistics on my index.php, in total 5 different ones.

To make it a bit easier, lets call them stats1, stats2, stats3, stats4, stats5.

This means that a query has to be run 5 times, to select the data, then sort them.

I was wondering if something like this could be done in a cronjob (lets say once a day) and that the results of those 5 querys would be inserted in a new table.

The newtable would be something like:
stats1_userid, stats1_username, stats1_posts, stats2_userid, stats2_username, stats2_posts, etc, etc.

While doing this, I could save 4 querys on my index.php, wich is heavily modded and I am desperate to look for something that could be done with less querys.

Is this possible? if yes, how?

Xenon 06-26-2005 04:59 PM

if you are using vb3 you can use the vb cron to fetch the needed data, then put everything into an php array, serialize that and put it into the datastore.
the vb datastore can be fetched without adding extra queries at all ($specialtemplates ;))

HakkieDEV 06-26-2005 09:50 PM

Okay, I figured out a way, but I don't understand that the page isn't showing faster.


OLD-------------------------------------------------------
Page generated in 4.02501 seconds with 43 queries [Server Loads: 0.08 0.07 : 0.15]
OLD-------------------------------------------------------



NEW-------------------------------------------------------
Page generated in 4.06289 seconds with 39 queries [Server Loads: 0.14 0.10 : 0.15]
NEW-------------------------------------------------------

Is it because the new table has 75 rows? :D

Any idea how I could get around this?

Xenon 06-27-2005 09:59 AM

i think there may be something else which takes too much time

HakkieDEV 06-27-2005 02:57 PM

So, 1 query that has to search in 75 rows is normally faster then 5 different querys to do the 75 rows?

Xenon 06-27-2005 03:26 PM

one query doing 75 rows shouldn't take 4 secounds at all ;)

Marco van Herwaarden 06-27-2005 03:53 PM

Well the number of returning rows don't always say something about the number of rows MySQL has to process, select, join and sort, before it can return that number of rows.

A select with a '...FROM singletable WHERE column = 1' that would select 75 out of the 150 rows, would be very fast.

Selecting from multiple big tables, joining on nonunique fields, sorting, etc, still returning 75 rows could be very time consuming.


All times are GMT. The time now is 04:17 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.01011 seconds
  • Memory Usage 1,715KB
  • 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)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete