is it helpful for the optimiser/planner to add LIMIT 1

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: <pgsql-general(at)postgresql(dot)org>
Subject: is it helpful for the optimiser/planner to add LIMIT 1
Date: 2008-04-03 10:28:43
Message-ID: 20080403122843.5e1c74ba@webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm reviewing some function I wrote to add stable, immutable where
needed and I'd like to take the chance to add further "cheap"
optimisation if it helps.

There are many places where I know a function or a statement will
return just one row?

Is it helpful to add LIMIT 1?

eg.
select a, b from myfunction(3,5) limit 1;
select into a,b x,y from tablename where z=5 and u=7 limit 1;
select a,b from from tablename where z=5 and u=7 limit 1;

thx

--
Ivan Sergio Borgonovo
http://www.webthatworks.it

Responses

Browse pgsql-general by date

  From Date Subject
Next Message windwxc 2008-04-03 11:13:43 question about complex type
Previous Message Ian Sillitoe 2008-04-03 10:00:46 Re: (FAQ?) JOIN condition - 'WHERE NULL = NULL'