LIMIT clause optimization - Mailing list pgsql-general

From Felipe Schnack
Subject LIMIT clause optimization
Date
Msg-id 1041940047.6599.12.camel@desenv1.ritterdosreis.br
Whole thread Raw
Responses Re: LIMIT clause optimization
List pgsql-general
  I was wondering... (a newbie starting to understand how to optimize
queries)
  In which step of query execution the LIMIT clause is executed? I mean
I have a query that would return, let's say, 6 rows, but I add a "LIMIT
1" in the end of it.
  I would speed up things because I would have less data fetching from
the database, right?
  But let's go to a extreme case. I just want to check if a query
returns data at all, so I did the following query:
  select 1 from <tablename>
  Seems fair, right? And what would be the difference in query
optimization if I did the following (i know i'm doing strange stuff):
  select 1 from <tablename> limit 1

--

Felipe Schnack
Analista de Sistemas
felipes@ritterdosreis.br
Cel.: (51)91287530
Linux Counter #281893

Centro Universitário Ritter dos Reis
http://www.ritterdosreis.br
ritter@ritterdosreis.br
Fone/Fax.: (51)32303341


pgsql-general by date:

Previous
From: Dan Langille
Date:
Subject: Re: [HACKERS] Have people taken a look at pgdiff yet?
Next
From: Achilleus Mantzios
Date:
Subject: Re: [SQL] 7.3.1 index use / performance