Re: [PERFORM] Subquery WHERE IN or WHERE EXISTS faster?

2008-07-05 Thread Sergio Gabriel Rodriguez
Hi Ulrich, do you try with SELECT p.speed FROM processor p INNER JOIN users_processors up ON p.id=up.processorid AND up.userid=1 ? Or your question is only about IN and EXIST? regards, Sergio Gabriel Rodriguez Corrientes - Argentina http://www.3trex.com.ar On Sat, Jun 28,

Re: [PERFORM] Subquery WHERE IN or WHERE EXISTS faster?

2008-07-05 Thread Sergio Gabriel Rodriguez
Hi Ulrich, do you try with SELECT p.speed FROM processor p INNER JOIN users_processors up ON p.id=up.processorid AND up.userid=1 ? Or your question is only about IN and EXIST? regards, Sergio Gabriel Rodriguez Corrientes - Argentina http://www.3trex.com.ar On Mon, Jun 30,

Re: [PERFORM] Subquery WHERE IN or WHERE EXISTS faster?

2008-06-30 Thread Rusty Conover
On Jun 30, 2008, at 1:29 AM, Ulrich wrote: I think it will be fast, because the "IN set", which is the result of "SELECT processorid FROM users_processors WHERE userid=4040", is limited to a maximum of ~500 processors which is not very big. Increasing Postgres' RAM would be difficult for m

Re: [PERFORM] Subquery WHERE IN or WHERE EXISTS faster?

2008-06-30 Thread Ulrich
I think it will be fast, because the "IN set", which is the result of "SELECT processorid FROM users_processors WHERE userid=4040", is limited to a maximum of ~500 processors which is not very big. Increasing Postgres' RAM would be difficult for me, because I am only running a very small server

Re: [PERFORM] Subquery WHERE IN or WHERE EXISTS faster?

2008-06-29 Thread Rusty Conover
On Jun 28, 2008, at 4:07 PM, Ulrich wrote: Hi, I have added a bit of dummy Data, 10 processors, 1 users, each user got around 12 processors. I have tested both queries. First of all, I was surprised that it is that fast :) Here are the results: EXPLAIN ANALYZE SELECT speed FRO

Re: [PERFORM] Subquery WHERE IN or WHERE EXISTS faster?

2008-06-29 Thread Tom Lane
"Jaime Casanova" <[EMAIL PROTECTED]> writes: > i've made some queries run faster using EXISTS instead of large IN > clauses... actually, it was NOT EXISTS replacing a NOT IN That's just about entirely unrelated ... regards, tom lane -- Sent via pgsql-performance mailing

Re: [PERFORM] Subquery WHERE IN or WHERE EXISTS faster?

2008-06-29 Thread Jaime Casanova
On Sat, Jun 28, 2008 at 10:53 AM, Tom Lane <[EMAIL PROTECTED]> wrote: > Ulrich <[EMAIL PROTECTED]> writes: >> People say that [EXISTS is faster] > > People who say that are not reliable authorities, at least as far as > Postgres is concerned. But it is always a bad idea to extrapolate > results on

Re: [PERFORM] Subquery WHERE IN or WHERE EXISTS faster?

2008-06-29 Thread Gregory Stark
"Ulrich" <[EMAIL PROTECTED]> writes: > Hi, > Yes that looks strange. But it is not possible that I have processors in > "users_processors" which do not appear in "processors", because > "users_processors" contains foreign keys to "processors". > > If I remove the LIMIT 10 OFFSET 1 the line "Sort (

Re: [PERFORM] Subquery WHERE IN or WHERE EXISTS faster?

2008-06-29 Thread Ulrich
Hi, Yes that looks strange. But it is not possible that I have processors in "users_processors" which do not appear in "processors", because "users_processors" contains foreign keys to "processors". If I remove the LIMIT 10 OFFSET 1 the line "Sort (cost= rows=11.." disappears and the quer

Re: [PERFORM] Subquery WHERE IN or WHERE EXISTS faster?

2008-06-28 Thread Gregory Stark
"Ulrich" <[EMAIL PROTECTED]> writes: > EXPLAIN ANALYZE SELECT speed FROM processors WHERE id IN (SELECT processorid > FROM users_processors WHERE userid=4040) ORDER BY speed ASC LIMIT 10 OFFSET 1; > > Limit (cost=113.73..113.75 rows=7 width=5) (actual time=0.335..0.340 rows=10 > loops=1) > ->

Re: [PERFORM] Subquery WHERE IN or WHERE EXISTS faster?

2008-06-28 Thread Ulrich
Hi, I have added a bit of dummy Data, 10 processors, 1 users, each user got around 12 processors. I have tested both queries. First of all, I was surprised that it is that fast :) Here are the results: EXPLAIN ANALYZE SELECT speed FROM processors WHERE id IN (SELECT processorid FRO

Re: [PERFORM] Subquery WHERE IN or WHERE EXISTS faster?

2008-06-28 Thread Tom Lane
Ulrich <[EMAIL PROTECTED]> writes: > People say that [EXISTS is faster] People who say that are not reliable authorities, at least as far as Postgres is concerned. But it is always a bad idea to extrapolate results on toy tables to large tables --- quite aside from measurement noise and caching i

[PERFORM] Subquery WHERE IN or WHERE EXISTS faster?

2008-06-28 Thread Ulrich
Hi, I am new to SQL and have two tables..., "processor" and "users_processors". The first table contains Processors: CREATE TABLE processor ( id SERIAL, speed varchar(50) NOT NULL, type int2 NOT NULL, PRIMARY KEY (id) ); CREATE UNIQUE INDEX processor_speed_index ON processors(lower(speed)); E