PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Ordering of table rows before selection (optimization problem)
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Ordering of table rows before selection (optimization problem)

Réponse
 
LinkBack Outils de la discussion
Vieux 02/02/2008, 23h12   #1
Kurda Yon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Ordering of table rows before selection (optimization problem)

Hi,

I have to extract elements from a table ordered in a special way. For
example
select id,name from table_name order by age*weight;

It seems to be not efficient to order rows each time when I extract
information from the table. Is that possible to keep table-rows in
specific order? In other words I want to order rows of the table once
(and force the table to remember this order), so the mysql-server does
not need to order the rows each time when I "select" rows from the
table (because the rows in the table will be already in the correct
ordered).

And the second question. What should I do if i need NOT all rows of
the table but only top 10?

Thank you.
  Réponse avec citation
Vieux 03/02/2008, 12h25   #2
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Ordering of table rows before selection (optimization problem)

Kurda Yon wrote:
> Hi,
>
> I have to extract elements from a table ordered in a special way. For
> example
> select id,name from table_name order by age*weight;
>
> It seems to be not efficient to order rows each time when I extract
> information from the table. Is that possible to keep table-rows in
> specific order? In other words I want to order rows of the table once
> (and force the table to remember this order), so the mysql-server does
> not need to order the rows each time when I "select" rows from the
> table (because the rows in the table will be already in the correct
> ordered).
>
> And the second question. What should I do if i need NOT all rows of
> the table but only top 10?
>
> Thank you.


Create an index holding your chosen value


  Réponse avec citation
Vieux 04/02/2008, 02h47   #3
Kurda Yon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Ordering of table rows before selection (optimization problem)

>
> Create an index holding your chosen value


Is that possible to extract only top 10 elements?
  Réponse avec citation
Vieux 04/02/2008, 09h53   #4
Luuk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Ordering of table rows before selection (optimization problem)


"Kurda Yon" <kurdayon@yahoo.com> schreef in bericht
news:cf45bcd7-fa0d-4cfb-9f3b-a3e21b9fa1de@k39g2000hsf.googlegroups.com...
> >
>> Create an index holding your chosen value

>
> Is that possible to extract only top 10 elements?


start reading:
http://dev.mysql.com/doc/refman/5.0/en/select.html
especially the part about LIMIT


  Réponse avec citation
Vieux 05/02/2008, 01h46   #5
Kurda Yon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Ordering of table rows before selection (optimization problem)

>
> Create an index holding your chosen value

Do you mean "primary key"? The problem is that the column declared
with the primary key should hold _unique_ values. In my case, some
rows can have the same value of the argument which I want to use for
the ordering.
  Réponse avec citation
Vieux 05/02/2008, 11h29   #6
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Ordering of table rows before selection (optimization problem)

On 5 Feb, 00:46, Kurda Yon <kurda...@yahoo.com> wrote:
> > Create an index holding your chosen value

>
> Do you mean "primary key"? The problem is that the column declared
> with the primary key should hold _unique_ values. In my case, some
> rows can have the same value of the argument which I want to use for
> the ordering.


No, I mean create an index. An index can be a unique or a non-unique
index.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 01h47.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12522 seconds with 14 queries