From: | Dmitri Touretsky <dmitri(at)listsoft(dot)ru> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Another stupid question :) |
Date: | 2002-12-04 03:02:41 |
Message-ID: | 189177874429.20021204060241@listsoft.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Good time of the day!
There are three tables:
CREATE big (
id int4 PRIMARY KEY,
ref1 int4,
ref2 int4,
...
);
CREATE ref1 (
id int4 PRIMARY KEY,
...
);
CREATE ref2 (
id int4 PRIMARY KEY,
...
);
Tables ref1 and ref2 are small, like 10-15 records. Table big is
large. Often I need to get data from all tables. Which way is better
in terms on performance:
SELECT big.*, ref1.*, ref2.* FROM big, ref1, ref2 WHERE big.ref1 =
ref1.id AND big.ref2 = ref2.id AND ...
OR make 3 separate queries like, say
SELECT * FROM big WHERE ...
and then in the loop select corresponding data from small tables?
And more general question: how queries affect performance? Which way
is better: run two queries which will return, say, 5 records each, or
run one query which will return, say, 20 records and then drop
unneeded records in my backend application?
Best regards,
Dmitri ( mailto:dmitri(at)listsoft(dot)ru )
New SOFT daily (RUS): http://www.listsoft.ru/
(ENG): http://www.listsoft.com/
Articles, tips : http://www.diskovod.ru/
---
Ошибок не прощают женщины и тетрис на 9й скорости.
From | Date | Subject | |
---|---|---|---|
Next Message | Glenn English | 2002-12-04 03:36:15 | Re: installation.. |
Previous Message | Miro Kralovic | 2002-12-04 02:30:08 | installation.. |