SubQuery speed
От | andreas.fredriksson@pacer.se |
---|---|
Тема | SubQuery speed |
Дата | |
Msg-id | Pine.LNX.4.00.9809081635420.676-100000@zenith.pacer.se обсуждение исходный текст |
Ответы |
Re: [SQL] SubQuery speed
|
Список | pgsql-sql |
Hi, I'm writing a indexed web search, stuffing some data into a few pgsql tables. The query involved can look something like: BEGIN; DECLARE CURSOR curs FOR SELECT url,title FROM idx_files WHERE id IN ( SELECT file_id FROM idx_ref WHERE word_id IN ( SELECT id FROM idx_words WHERE word = 'search term 1' OR .. ) ); FETCH FORWARD 10 IN curs; END; The idx_files table holds about 1.000 rows, the idx_words table holds about 50.000 words, and the idx_ref is a massive 250.000+ row cross-reference (file_id, word_id) which links the words and pages together. A query like the above took several hours on my Pentium 200 at work before I killed the stuck daemon. This is kind of strange since the innermost subquery is only suppose to return a single id. :-( Are there any alternate methods of solving this? I don't think it's possible to write this kind of query using a multi-JOIN? Thanks for your input, --- Andreas `dep' Fredriksson andreas.fredriksson@pacer.se Programmerare, Pacer Communication www.pacer.se, 08-665 34 10 Linux: Because rebooting is for adding new hardware.
В списке pgsql-sql по дате отправления: