LIMIT and JOINS

From: "Gregor Zeitlinger" <gregor(dot)zeitlinger(at)torexretail(dot)de>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: LIMIT and JOINS
Date: 2006-02-22 15:41:37
Message-ID: 5DE489C997EC984FA3DD0935879DAE1255EB3F@ex09-00-z002.torexretail.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I have a question on implementation of the LIMIT SQL clause.

Using the LIMIT clause, I want to reduce the computation time for a query.

When I try to limit the result of a joined table, however, the join will be computed first (which takes very long).

Lets suppose the following example:

select * from T1 join T2 on T1.id = T2.id LIMIT 1

Conceptually, it should be possible to fetch one row from T1 and T2, i.e. to propagate the LIMIT clause.

I was wondering what the exact requirements are to propagate the LIMIT clause.

Do I need a foreign key relation between T1 and T2?
Do I need to use a full outer join in order to propagate the LIMIT clause?

Thanks

Gregor Zeitlinger
LUCAS Product Development

Torex Retail Solutions GmbH

Schwedenstr. 9, D-13359 Berlin
Tel. +49 (0) 30 49901-243
Fax +49 (0) 30 49901-139

Mailto:gregor(dot)zeitlinger(at)torexretail(dot)de <mailto:gregor(dot)zeitlinger(at)torexretail(dot)de>
http://www.torexretail.de <http://www.torexretail.de/>

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-02-22 15:55:26 Re: LIMIT and JOINS
Previous Message Tom Lane 2006-02-22 15:27:57 Re: Request: set opclass for generated unique and primary key indexes