Another suggestion - use explicit joins.
  SELECT c.*, p.province, co.country
    FROM test.cities AS c LEFT JOIN test.countries AS co USING(country_c)
LEFT JOIN test.provinces AS p ON c.province_no=p.province_id
ORDER BY country , province
  limit 0, 10;

This might work. If not read the docs at http://www.mysql.com/doc/
about joins and how to do LEFT(RIGHT) JOIN.

Good luck.

Andrey
 
----- Original Message ----- 
From: "Andy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, March 31, 2002 6:29 PM
Subject: [PHP-DB] LIMIT 0,10 retrieves 10 records, but takes forever!


> Hi there,
> 
> I am having a problem understanding how limit works. As I thought limit
> restricts the amount of results
> to a given number. True.. the number of results is only that high how high I
> specify it with limit.
> 
> But the querry takes as long as without limit. I am trying to avoid to long
> waiting times if a user is
> by exident searching for to many records.
> 
> This is my querry:
> 
>  SELECT c.*, p.province, co.country
>  FROM test.cities c, test.provinces p, test.countries co
>  WHERE c.city like 'd%'
>   AND p.province_no = c.province_id
>   AND p.country_c = c.country_c
>   AND c.country_c = co.country_c
>  ORDER BY country , province
>  limit 0, 10
> 
> This takes 30 s on a 2.5 mio entries table
> 
> How could I really restrict the results to 10. So that mysql just returns
> after 10 results?
> 
> Thanx, Andy
> 
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to