473,624 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ALTER TABLE `table` ORDER BY `column_a` DESC

I try to get better performance by implementing this:

http://dev.mysql.com/doc/mysql/en/alter-table.html

"ORDER BY allows you to create the new table with the rows in a
specific order. Note that the table does not remain in this order after
inserts and deletes. This option is mainly useful when you know that
you are mostly going to query the rows in a certain order; by using
this option after big changes to the table, you might be able to get
higher performance. In some cases, it might make sorting easier for
MySQL if the table is in order by the column that you want to order it
by later."

Here is the steps:

I run this SQL query on one of the table:
"ALTER TABLE `table` ORDER BY `column_a` DESC"

Then, i browse the table:
"SELECT * FROM `table` LIMIT 0, 30"
The rows of data is arranged in expected order (column_a DESC)

However when i add a where definition:
"SELECT * FROM `table` WHERE column_b = 'b' LIMIT 0, 30"
Then, the result is arranged in PRIMARY KEY ASC

So, if i want the result to display in order of 'column_a DESC', i have
to append 'ORDER BY column_a DESC' at SQL query, and this will affect
the performance.

Am i did anything wrong?
Or
Someone please advise me on how to make use of the advantage as
described at 'http://dev.mysql.com/doc/mysql/en/alter-table.html

FYI. i running MySQL 4.0.24 on Linux Fedora 3

Jul 23 '05 #1
1 17116
bo*****@gmail.c om wrote:
Someone please advise me on how to make use of the advantage as
described at 'http://dev.mysql.com/doc/mysql/en/alter-table.html


I would never use that feature. It isn't reliable, as they describe in
the web page, because it changes if you change the data in the table.
Queries should behave consistently given the same set of data. For the
query to behave differently based on the history of changes to the table
breaks consistency. This is not good for a relational database (yeah, I
know MySQL doesn't pass the ACID test by default, but this makes it
worse than usual).

I can't imagine that the difference in performance would be sufficiently
greater than what you can get by using SELECT ... ORDER BY over an
indexed field to justify the hassle in keeping it working.

IMHO, that feature is useless as it is implemented, and it should be
avoided.

Put ORDER BY clauses in all of your SELECT queries where the order is
important. That method is reliable.

Regards,
Bill K.
Jul 23 '05 #2

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

Similar topics

2
14335
by: Ittay Freiman | last post by:
i cannot set auto_increment to start from anything other than 1: mysql> create table test (id int unsigned not null auto_increment primary key); mysql> alter table test auto_increment=2; mysql> insert into test() values(); mysql> select * from test; +----+
2
1872
by: Gordowey | last post by:
I have the next question, and i would like to hear what do you think about, and if is there a better solution for "my problem" here is the question, I have a huge table with 60GB of data (image files). The problem happen always when i try to ALTER the structure of the table. For example I change a field char(3) to char(4)...the sqlserver then performs the "alter table" command...that must be something similar than "insert into the new...
0
2247
by: EddieA | last post by:
Does anyone know how to set the Sort Order for a Pivot Table when you want the data to be sorted on a field that is available but not placed on the Pivot Table. My situation is that I've got these text based catagories that have Sequential Level numbers. The catagories are on the column axis, showing up alphabetically. Not what I want. I'd like them sorted by their Level Numbers, even though these numbers are not on the table. Any...
1
1950
by: Henri Schomäcker | last post by:
Hi folks, what I need is a kind of 2D-Array which should, in the end, represent a typical html-table and which should be sortable by column. I thought of an implementation, where an vector does not keep the rows, as usual, but holds the single _columns_ as lists. In this case, every column could have it's own datatype, just like database-tables and could be sortable by the list's sort function.
10
2234
by: ste | last post by:
Hi there, I'm trying to query a MySQL database (containing image data) and to output the results in a HTML table of 3 columns wide (and however many rows it takes) in order to create a basic thumbnail gallery. I can query and output the data as a single column table, but I'm having problems filling up a 3 column table (with different images, looping continuously until the end).
7
6974
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get into the GUI because it is hard to describe in text. First of all what is the purpose of ALTOBJ()? This procedure was created mostly for ISVs who need to do produce change scripts to upgrade application from release to release, but it can also
0
6038
by: samui | last post by:
Syntax is ORDER BY column_name ASC|DESC, so your statement: $res = mysql_query("SELECT * FROM EWT WHERE $field='$findit' ORDER BY $orderby DESC;") Ronald :cool:
1
8426
by: Pacific Fox | last post by:
Hi all, I have a SQL statement that allows paging and dynamic sorting of the columns, but what I can't figure out without making the SQL a dynamic string and executing it, or duplicating the SQL statement between an IF and ELSE statement. Following is the SQL statement; set ANSI_NULLS ON
7
25318
ak1dnar
by: ak1dnar | last post by:
Hi this is my first visit to the MSSQL forum with a question. Let me explain the scenario, I have a table say clients table with the structure like id,foo,etc.. and lots of records on it. But the issue is this id column is not an IDENTITY column. But the values for the Id column don’t repeat since it has handled from the application level.Now I need to change this id column as an IDENTITY column with out loosing the records on the table....
0
8175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8625
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7168
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2610
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.