In the last episode (Jul 23), Jan Peuker said:
> Dan Nelson wrote:
> > So what you really want is
> >
> > CREATE TEMPORARY TABLE tmp
> >  SELECT code FROM mytable WHERE zip < 12345 ORDER BY zip DESC LIMIT 5;
> > INSERT INTO tmp
> >  SELECT code FROM mytable WHERE zip = 12345;
> > INSERT INTO tmp
> >  SELECT code FROM mytable WHERE zip > 12345 ORDER BY zip LIMIT 5;
> > SELECT code FROM tmp ORDER BY zip;
> > DROP TABLE tmp;
>
> Hi Dan,
> 
> that's exactly what I do. But it's not that fast, I missed 2 '0''s, the
> table has 10000 rows (which is still not big, I think), but zip is only
> index. The "procedure" takes over a second, and that (that's the point) for
> every user and every query.
> But now I think it's the only way.

Even without indexes, a query on a table with only 10000 rows should be
just about instantaneous.  I tried the exact same set of commands on a
4 million record table here, and the whole set of queries takes .04
second.

Try explaining each select and make sure they are using an index.

-- 
        Dan Nelson
        [EMAIL PROTECTED]

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to