Re: [SQL] query with subquery abnormally slow?
От | Moray McConnachie |
---|---|
Тема | Re: [SQL] query with subquery abnormally slow? |
Дата | |
Msg-id | 00a001bf24a3$96a18460$01c8a8c0@malthouse.private.net обсуждение исходный текст |
Ответ на | query with subquery abnormally slow? (Oskar Liljeblad <osk@hem.passagen.se>) |
Ответы |
Re: [SQL] query with subquery abnormally slow?
|
Список | pgsql-sql |
> select * > from items > where package in > (select package > from items > where ...blah... > group by package) Can't see why you don't rewrite this as one query: select * from items where ... blah ... order by package; (is it aggregates in the where clause?) Assuming you do need to do it the way you have done it , SELECT * FROM items WHERE NOT EXISTS (SELECT package FROM items itemscopy WHERE ... blah ... AND itemscopy.itemid=items.itemid GROUP BY package); should do it. itemid should be replaced by whatever the primary key of the items table is. Note that in blah, fields must be referred to as itemcopy.field1,itemcopy.field2, etc. Yours, Moray McConnachie
В списке pgsql-sql по дате отправления: