Re: Unnecessary function calls - Mailing list pgsql-general

From Markus Schiltknecht
Subject Re: Unnecessary function calls
Date
Msg-id 1146572866.18433.64.camel@fotomarburg
Whole thread Raw
In response to Re: Unnecessary function calls  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
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



pgsql-general by date:

Previous
From: Terry Fielder
Date:
Subject: Re: Unnecessary function calls
Next
From: Terry Fielder
Date:
Subject: Re: Unnecessary function calls