The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
MyChenQL queries
Or MySQL in this case...any way to optimize this query so it doesn't take so obscenely long to execute? What it's supposed to do (and what I think it is doing) is return the number of posts that were created durning each of the 24 hours in a day.
Code:
mysql> SELECT HOUR(FROM_UNIXTIME(dateline)), COUNT(*) FROM post GROUP BY HOUR(FROM_UNIXTIME(dateline)); +-------------------------------+----------+ | HOUR(FROM_UNIXTIME(dateline)) | COUNT(*) | +-------------------------------+----------+ | 0 | 941 | | 1 | 1006 | | 2 | 560 | | 3 | 597 | | 4 | 534 | | 5 | 533 | | 6 | 664 | | 7 | 888 | | 8 | 978 | | 9 | 1225 | | 10 | 1670 | | 11 | 2017 | | 12 | 1707 | | 13 | 1886 | | 14 | 1980 | | 15 | 2658 | | 16 | 3196 | | 17 | 4150 | | 18 | 4418 | | 19 | 3134 | | 20 | 3503 | | 21 | 3523 | | 22 | 2600 | | 23 | 1595 | +-------------------------------+----------+ 24 rows in set (1.72 sec) |
#2
|
||||
|
||||
24 rows in set (3.24 sec)
A little slow... hehehe I'm curious about how to optimize this query too |
#3
|
|||
|
|||
Your best bet is to run something like "SELECT dateline FROM post" and then do the sorting of the reuslts with php.
|
#4
|
|||
|
|||
Problem is that will return almost 50,000 rows and make PHP have to do all the work
|
#5
|
|||
|
|||
BTW out of curiousity why do you need this?
|
#6
|
|||
|
|||
For a mod/hack I'm making that will show a graph of posts per hour.
|
#7
|
|||
|
|||
I'm assuming this is some sort of a statistical thing. Just create a cronjob that does this slow query once every 12 hours (or osmething like that) and stores the results. Whenever someone loads the stats page show the stored results with something like "last updated at 12 pm today".
|
#8
|
|||
|
|||
Hmm, good idea although I would have prefered something realtime
|
#9
|
||||
|
||||
Perhaps an index on the dateline field may speed this up, just a thought, I've no real idea if that will help or not without trying it.
|
#10
|
|||
|
|||
Quote:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|