The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. November 21, 2008, 06:57:26 AM

Login with username, password and session length


Pages: 1 [2]
  Print  
Author Topic: MySQL - finding the row with the most in [x] column  (Read 532 times)
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 5138


:sniffle: Humor was so much easier before.


View Profile
« Reply #15 on: July 17, 2008, 11:23:22 AM »

I'd bet the speed difference would actually come into play more with a subquery than between MAX and order by. Since the row result is so small (always will be) and MySQL creates you a temp table anyway, I think it's probably a wash.

In the subquery method, there are two walks across the table, where with the order by/DESC/limit 1 method is only 1 walk, but it creates a temporary table that is probably the full size of the original result set and then only returns the first row.

Dog - do you have any thoughts on this re. speed, particularly if this question was raised against a much larger dataset?
Logged

If I can't be Mr. Root then I don't want to play.
Pages: 1 [2]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!