473,382 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Equivalent expressions

Given a primary key field `RecNo` -

Are there any performance reasons to favor one of these two otherwise
equivalant expressions?

SELECT MAX(RecNo)
FROM SomeTable;

SELECT RecNo
FROM SomeTable
ORDER BY RecNo DESC
LIMIT 1;

Just curious.
Thomas Bartkus
Aug 22 '06 #1
1 3399

Thomas Bartkus wrote:
Given a primary key field `RecNo` -

Are there any performance reasons to favor one of these two otherwise
equivalant expressions?

SELECT MAX(RecNo)
FROM SomeTable;

SELECT RecNo
FROM SomeTable
ORDER BY RecNo DESC
LIMIT 1;

Just curious.
Thomas Bartkus
I think the performance differences (if any) would be easy enough to
test yourself.
Note though that there are at least a couple of situations where these
queries are not equivalent: If, for instance, a NULL value was provided
then this would appear at the top of the second query.

Aug 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert Dodier | last post by:
Hello, Here's a thought that I'm sure has already occurred to someone else, I just can't find any record of it yet. An XML document is just a more verbose and clumsy representation of an...
4
by: Susan Baker | last post by:
Hi, I'm working on s simple parser and I would like to split up multi-line expressions into single expressions. Is there a way whereby I could slurp the lines into an array (or other container)?...
24
by: hjbortol | last post by:
Hi! Is the expression "a >= b" equivalent to "a - b >= 0" in C/C++? Is this equivalence an IEEE/ANSI rule? Or is this machine/compiler dependent? Any references are welcome! Thanks in...
11
by: Kobu | last post by:
Hi, I've gotten into the habit of mentally converting big expressions to parse tress (started doing this after reading some c.l.c posts on parse trees). Can someone verify if the following...
8
by: Xucyr | last post by:
I can't find any "short" code to make this work without taking 100s of lines (because I have to keep repeating this process several times). But this is what I have so far: int i = 7; do {...
3
by: Tim Soliday | last post by:
I have been looking at regular expressions lately, and I'm hoping that maybe someone could help me? I am trying to find the position of a substring, and then returning the substring including...
14
by: Michael McCarthy | last post by:
This code is supposed to create a streamreader object from a stream object and I suppose use encoding if requested (enc isn't null)... The second bit is someone elses code... /// code block #1...
14
by: grid | last post by:
Hi, I have a certain situation where a particular piece of code works on a particular compiler but fails on another proprietary compiler.It seems to have been fixed but I just want to confirm if...
6
by: Jon Paal | last post by:
what is vb equiv. of ++ shown in C# ?
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.