Re: How to optimize ugly order by?

2004-03-25 Thread Don Read
On 24-Mar-2004 Henrik Schröder wrote: snip No, I did not choose the sort order. No, I can not change the values used. Yes, it has to be this sort order. :-) Best would be to use ENUM( '1','2','0') ... But otherwise -- (membershiptype % 2) DESC, membershiptype DESC -- or --

How to optimize ugly order by?

2004-03-24 Thread Henrik Schröder
Hi all, I have a table of users which contains a lot of information, and also a column called membershiptype which can either be 0, 1, or 2. This table is used a lot in various searches, and all results should be ordered by membership type, but the order should not be 0-1-2, but instead 1-2-0.

Re: How to optimize ugly order by?

2004-03-24 Thread Victor Pendleton
Does the where clause contain the order by columns? If not, then you will have a filesort no matter what. On Wed, 24 Mar 2004, Henrik Schröder wrote: Hi all, I have a table of users which contains a lot of information, and also a column called membershiptype which can either be 0, 1, or 2.

Re: How to optimize ugly order by?

2004-03-24 Thread Jigal van Hemert
From: Henrik Schröder [EMAIL PROTECTED] used a lot in various searches, and all results should be ordered by membership type, but the order should not be 0-1-2, but instead 1-2-0. One thing you could do (not very neat IMHO) is to JOIN this query with a table that contains membershiptype and a

Re: How to optimize ugly order by?

2004-03-24 Thread Victor Pendleton
Let me rephrase my statement. Does the index being used include the order by columns? If not, the optimizer will not be able to perform both row selection and row ordering in the same pass. On Wed, 24 Mar 2004, Victor Pendleton wrote: Does the where clause contain the order by columns? If not,

Re: How to optimize ugly order by?

2004-03-24 Thread Tim McDonough
On Wed, 24 Mar 2004 15:47:46 +0100, Henrik Schröder wrote: I have a table of users which contains a lot of information, and also a column called membershiptype which can either be 0, 1, or 2. This table is used a lot in various searches, and all results should be ordered by membership type,

RE: How to optimize ugly order by?

2004-03-24 Thread Henrik Schröder
- From: Victor Pendleton [mailto:[EMAIL PROTECTED] Sent: den 24 mars 2004 16:22 To: [EMAIL PROTECTED]; Henrik Schröder; '[EMAIL PROTECTED]' Subject: Re: How to optimize ugly order by? Let me rephrase my statement. Does the index being used include the order by columns? If not, the optimizer

RE: How to optimize ugly order by?

2004-03-24 Thread Henrik Schröder
Hemert [mailto:[EMAIL PROTECTED] Sent: den 24 mars 2004 16:12 To: [EMAIL PROTECTED] Subject: Re: How to optimize ugly order by? From: Henrik Schröder [EMAIL PROTECTED] used a lot in various searches, and all results should be ordered by membership type, but the order should not be 0-1-2

RE: How to optimize ugly order by?

2004-03-24 Thread Victor Pendleton
the biggest problem, right? /Henrik -Original Message- From: Victor Pendleton [mailto:[EMAIL PROTECTED] Sent: den 24 mars 2004 16:22 To: [EMAIL PROTECTED]; Henrik Schröder; '[EMAIL PROTECTED]' Subject: Re: How to optimize ugly order by? Let me rephrase my statement. Does

Re: How to optimize ugly order by?

2004-03-24 Thread Brent Baisley
I assume you are just trying to make things more readable. As far as I know, MySQL does not support custom sort orders, except when a field is an enum or a set. Even then, that's not a custom order since your still sorting on the underlying values. You could do something like this for

Re: How to optimize ugly order by?

2004-03-24 Thread Michael Stassen
Henrik Schröder wrote: Hi all, I have a table of users which contains a lot of information, and also a column called membershiptype which can either be 0, 1, or 2. This table is used a lot in various searches, and all results should be ordered by membership type, but the order should not be

Re: How to optimize ugly order by?

2004-03-24 Thread Dave Dash
Can you do: SELECT IF(membershiptype = 0, 3, membershiptype) AS s1 FROM... ORDER BY s1 Shouldn't that work? Basically if mtype is 0 return 3 otherwise return the membership type... and sort by that field. lemme know if that works or if I'm dead wrong ;) Henrik Schröder wrote: Hi all,