LIMIT and JOINS - Mailing list pgsql-hackers

From Gregor Zeitlinger
Subject LIMIT and JOINS
Date
Msg-id 5DE489C997EC984FA3DD0935879DAE1255EB3F@ex09-00-z002.torexretail.de
Whole thread
Responses Re: LIMIT and JOINS
List 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.zeitlinger@torexretail.de

http://www.torexretail.de

 

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Request: set opclass for generated unique and primary key indexes
Next
From: Tom Lane
Date:
Subject: Re: LIMIT and JOINS