| From: | Markus Schiltknecht <markus(at)bluegap(dot)ch> |
|---|---|
| To: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Unnecessary function calls |
| Date: | 2006-05-02 12:27:46 |
| Message-ID: | 1146572866.18433.64.camel@fotomarburg |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Terry Fielder | 2006-05-02 12:31:16 | Re: Unnecessary function calls |
| Previous Message | Markus Schiltknecht | 2006-05-02 12:16:38 | Re: Unnecessary function calls |