Sub-select speed.

Поиск
Список
Период
Сортировка
От Mitch Vincent
Тема Sub-select speed.
Дата
Msg-id 018301bf48bf$8a068620$0300000a@doot.org
обсуждение исходный текст
Ответ на Re: [SQL] Search optimisation  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [SQL] Sub-select speed.  (Tom Lane <tgl@sss.pgh.pa.us>)
avg() on numeric ?  (<kaiq@realtyideas.com>)
Список pgsql-sql
Hey guys, I have a few queries here that I would greatly appreciate any
pointers on. I ned to get them as fast as possible but would settle for ANY
speed improvement over what it is now..

select * from applicants as a where a.status = 'A' and a.app_id in(select
b.app_id from resume_search as b where a.app_id=b.app_id and b.user_id=291)

resume_search is a table populated by a query before this one.  The schema
is as follows :
| user_id                          | int4                             |
4 |
| app_id                           | int4                             |
4 |

Indices:  resume_app_id             resume_search_id

So, in it's current form, with only a few (say 5) rows in resume_search,
it's still tking quite some time.

In addition to this, I have another query liek this one, only it inserts to
another table also..

insert into users_download_app (user_id,app_id) select app_id from
applicants where status = 'A' and app_id in(select b.app_id from
resume_search as b where app_id=b.app_id and b.user_id=291) limit 200

This one is so slow that it's unusable. (We're talking minutes here on my
Celeron 333 devel server).

I wish there was another way to get what I need to get done but the
sub-selects are the only way I can see doing it now. I have a feeling though
that there are some extra things that I might be able to do to get the same
results from the same tables, faster.

Thanks to one and all.

-Mitch







В списке pgsql-sql по дате отправления:

Предыдущее
От: kaf@ip146.usw5.rb1.bel.nwlink.com (Kyle)
Дата:
Сообщение: simple sql select help
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] Sub-select speed.