pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sebastian Hennebrueder <usenet@laliluna.de>
Cc: pgsql-performance@postgresql.org
Subject: Re: tricky query
Date: Tue, 28 Jun 2005 22:38:54 +0200
Message-ID: <42C1B55E.40405@laliluna.de> (raw)
In-Reply-To: <42C16FE4.2020803@arbash-meinel.com>
References: <6EE64EF3AB31D5448D0007DD34EEB3415C2BEC@Herge.rcsinc.local>
	<42C167C6.5070108@arbash-meinel.com>
	<42C16FE4.2020803@arbash-meinel.com>

John A Meinel schrieb:

> John A Meinel wrote:
>
>>
>
> Well, I was able to improve it to using appropriate index scans.
> Here is the query:
>
> SELECT t1.id+1 as id_new FROM id_test t1
>    WHERE NOT EXISTS
>        (SELECT t2.id FROM id_test t2 WHERE t2.id = t1.id+1)
>    ORDER BY t1.id LIMIT 1;
>
> I created a test table which has 90k randomly inserted rows. And this is
> what EXPLAIN ANALYZE says:
>
>        


As Cosimo stated the result can be wrong. The result is always wrong
when the id with value 1 does not exist.

-- 
Best Regards / Viele Grüße

Sebastian Hennebrueder

----

http://www.laliluna.de

Tutorials for JSP, JavaServer Faces, Struts, Hibernate and EJB 

Get support, education and consulting for these technologies - uncomplicated and cheap.




view thread (19+ messages)  latest in thread

Message-ID: <42C1B55E.40405@laliluna.de>
Permalink:  ../42C1B55E.40405@laliluna.de/
Also on:    postgresql.org/message-id/42C1B55E.40405@laliluna.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: usenet@laliluna.de
  Subject: Re: tricky query
  In-Reply-To: <42C1B55E.40405@laliluna.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox