List:General Discussion« Previous MessageNext Message »
From:Johnny Withers Date:August 18 2009 8:19pm
Subject:Re: Query Question
View as plain text  
It may be true that "some DBMSs" physically store rows in whatever order you
speicfy; however, this is a MySQL list, and MySQL does not do this (InnoDB
anyway).

For example, take a table with 10,000,000 rows and run a simple select on
it:

Database changed
mysql> SELECT id FROM trans_item LIMIT 1\G
*************************** 1. row ***************************
id: 8919552
1 row in set (0.08 sec)
mysql> SELECT id FROM trans_item ORDER BY id ASC LIMIT 1\G
*************************** 1. row ***************************
id: 8441275
1 row in set (0.08 sec)

Sure, the first query may always return that ID number; however, it may not.



On Tue, Aug 18, 2009 at 2:31 PM, Martijn Tonies <m.tonies@stripped>wrote:

>
>
> To further emphasize this point:  A table has no order by itself,
>>
>
> That's not entirely true ;-) Records are stored in some kind of physical
> order, some DBMSses implement clustered keys, meaning that the
> records are stored ascending order on disk.
>
> However...
>
> and you should make no assumptions about the order of rows you will get
>> back in a select statement, unless you use an ORDER BY clause.
>>
>
> This is correct in that a -result set- does not have an "order" defined
> unless you specify an ORDER BY clause.
>
> With regards,
>
> Martijn Tonies
> Upscene Productions
> http://www.upscene.com
>
> Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
> Anywhere, MySQL, InterBase, NexusDB and Firebird!
>
> Database questions? Check the forum:
> http://www.databasedevelopmentforum.com
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>
>


-- 
-----------------------------
Johnny Withers
601.209.4985
johnny@stripped

Thread
Query QuestionBill Arbuckle18 Aug
  • Re: Query QuestionWalter Heck - OlinData.com18 Aug
    • RE: Query QuestionGavin Towey18 Aug
  • Re: Query QuestionMartijn Tonies18 Aug
    • Re: Query QuestionJohnny Withers18 Aug
  • Re: Query QuestionMartijn Tonies18 Aug