joins and indexes -- a=b or b=a?

From: will trillich <will(at)serensoft(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: joins and indexes -- a=b or b=a?
Date: 2001-03-28 23:01:11
Message-ID: 20010328170111.B16380@mail.serensoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

if you have a main table on which you're doing a linear scan:

create table person (
id varchar(12), -- handle/id/login
name varchar(30),
gang int4
);

that joins another indexed table:

create table gang (
id serial,
name varchar(30),
primary key(id)
);

is there any significant difference in the following two queries:

select
p.id as handle, p.name as person, g.name as gang
from
person p, gang g
where
PERSON.GANG = GANG.ID
;

-- as opposed to:

select
p.id as handle, p.name as person, g.name as gang
from
person p, gang g
where
GANG.ID = PERSON.GANG
;

the only difference is GANG.ID=PERSON.GANG versus
PERSON.GANG=GANG.ID in the WHERE clause. does it matter?

--
It is always hazardous to ask "Why?" in science, but it is often
interesting to do so just the same.
-- Isaac Asimov, 'The Genetic Code'

will(at)serensoft(dot)com
http://newbieDoc.sourceforge.net/ -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message will trillich 2001-03-28 23:07:33 optimizing a view-driven query
Previous Message will trillich 2001-03-28 22:55:55 Re: how to load a sql-file????