Re: newbie optimization question

2006-04-20 Thread Adam Wolff
Hey! I figured out this one myself: On Apr 19, Adam Wolff wrote: > * Question 2: > Why does introducing an extra WHERE clause make things slower? > If I do this: > SELECT * FROM contacts WHERE fullname LIKE "j%" AND user_id=1 > ORDER BY fullname LIMIT 10; > It's because the index needs t

Re: newbie optimization question

2006-04-20 Thread Adam Wolff
Thanks for the replies. The database is basically read-only at the moment, so OPTIMIZE TABLE didn't do anything. When I force the key to be fullname for the second problem, it runs even worse. It's not practical to create an additional email,fullname index because in my app I actually have 3! c

Re: newbie optimization question

2006-04-20 Thread Alexey Polyakov
On 4/20/06, Adam Wolff <[EMAIL PROTECTED]> wrote: > How can I optimize the case where I filter on one key but sort on another? > This is fast: >SELECT * FROM contacts WHERE fullname LIKE "j%" ORDER BY fullname LIMIT 10; > > But this is slow: >SELECT * FROM contacts WHERE fullname LIKE "j%"

Re: newbie optimization question

2006-04-20 Thread Philippe Poelvoorde
Hi, 2006/4/20, Adam Wolff <[EMAIL PROTECTED]>: > Hi. I'm new to database optimization and I have a couple of questions. > > I have a table like this: > > +++-+-+ > | id | fullname | email | user_id | > +++-

newbie optimization question

2006-04-19 Thread Adam Wolff
Hi. I'm new to database optimization and I have a couple of questions. I have a table like this: +++-+-+ | id | fullname | email | user_id | +++-+-+ Where fullname and email are varchar(100) a