From: Miernik <public@public.miernik.name>
To: pgsql-performance@postgresql.org
Subject: what is less resource-intensive, WHERE id IN or INNER JOIN?
Date: Thu, 31 Jul 2008 00:11:58 +0200
Message-ID: <20080730221158.5323.1.NOFFLE@turbacz.local> (raw)
AFAIK, provided bar is UNIQUE in table2 (e.g. is a PRIMARY KEY) the two
queries will give the same result:
SELECT foo, id FROM table1 WHERE id IN (SELECT id FROM table2);
SELECT foo, id FROM table1 INNER JOIN table2 USING (id);
Given table1 has about 100k rows, and table2 about 100 rows, which one
should be faster, less resource intensive, use less RAM, disk access, etc?
Are there any other even better ways to acomlish the same query?
Using 8.3.3 on a 48 MB RAM Xen.
--
Miernik
http://miernik.name/
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: public@public.miernik.name
Subject: Re: what is less resource-intensive, WHERE id IN or INNER JOIN?
In-Reply-To: <20080730221158.5323.1.NOFFLE@turbacz.local>
* 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