On Tue, 2006-05-02 at 14:02 +0200, Martijn van Oosterhout wrote:
> How about:
> 
> SELECT id, get_category_text_path(id)
> FROM (SELECT id FROM category
>     ORDER BY rank
>     LIMIT 5) as x;

Oh that works? Great!

Let me see, with 'rank' from a joined table that looks like:

SELECT id, get_category_text_path(id), rank
FROM (
    SELECT c.id
    FROM category AS c
    JOIN rank_lookup AS r ON r.cat_id = c.id
    ORDER BY r.rank
    LIMIT 5
) as x;

That works perfectly. It prevents a second join and thus solves the
question in my previous mail.

> Evidently you don't have an index on rank, otherwise it would've used
> the index to cut down on the number of rows that needed to be examined.

No, there is no index. I need to think about creating one...

Thank you very much.

Markus



---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

Reply via email to