vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   stupid mysql question (https://vborg.vbsupport.ru/showthread.php?t=52402)

amykhar 05-01-2003 03:06 AM

stupid mysql question
 
I know it's easy and I think the word I am looking for is MAX, but how do I get the maximium value of a column in a table? For example, the highest userid in the user table?

I am bone tired and too wiped to go looking for it tonight.

The way I was doing it seems really slow when I look at debug. I was selecting 1 ordering by userid desc.

Thanks in advance. I owe somebody a cheerful answer to one stupid question :D

Amy

Erwin 05-01-2003 03:29 AM

Your way ordering in desc would work.

This would also work:

PHP Code:

SELECT MAX(useridFROM user

Much easier.

amykhar 05-01-2003 01:50 PM

Thank you Erwin. Yes, I know my way worked, but when I ran the board in debug mode I saw that it was taking a long time to run that query. I am trying to optimize a bit and thought I would try this. Thank you :)

Amy

amykhar 05-01-2003 02:01 PM

OMG I can't believe the difference changing those two queries made. Before, my forumhome took 1.4 seconds to load on average. I upgraded to mysql 4 and got it down to between .89 and 1.2 seconds.

Changing two queries to get the MAX correctly instead of my way means forumhome now loads in .30 seconds!

Amy


All times are GMT. The time now is 05:26 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.01025 seconds
  • Memory Usage 1,717KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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