Re: Query runs very slowly in Postgres, but very fast in other DBMS

Поиск
Список
Период
Сортировка
От Krasimir Dimitrov
Тема Re: Query runs very slowly in Postgres, but very fast in other DBMS
Дата
Msg-id 200504120933.17457.kr@aiidatapro.com
обсуждение исходный текст
Ответ на Query runs very slowly in Postgres, but very fast in other DBMS  ("Andrus Moor" <eetasoft@online.ee>)
Список pgsql-sql
try this query :

SELECT rid.dokumnr as d1 ,dok.dokumnr as d2  FROM rid left join dok on 
rid.dokumnr = dok.dokumnr where dok.dokumnr is null;


> Tables:
>
> CREATE TABLE dok ( dokumnr NUMERIC(12),
>             CONSTRAINT dok_pkey PRIMARY KEY (dokumnr) );
> CREATE TABLE rid ( dokumnr NUMERIC(12) );
> CREATE INDEX rid_dokumnr_idx ON rid (dokumnr);
>
> Query:
>
> SELECT dokumnr FROM rid WHERE dokumnr NOT IN
> (select dokumnr FROM dok);
>
> runs VERY slowly in Postgres. It uses the following query plan:
>
> Seq Scan on rid  (cost=0.00..28698461.07 rows=32201 width=14)
>   Filter: (NOT (subplan))
>   SubPlan
>     ->  Seq Scan on dok  (cost=0.00..864.29 rows=10729 width=14)
>
> In Microsoft Visual FoxPro this query runs fast. FoxPro uses indexes speed
> up the query by comparing bitmaps.
>
> Is it possible to speed up this query is Postgres ? How to force Postgres
> to use indexes for this query ?
>
> Andrus
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)



-- 
________________________________________________________
Krasimir Dimitrov
IT Department
AII Data Processing Ltd.,
16 Ivan Vazov Str,
Sofia 1000,
Bulgaria
Phone: +359 2 9376 352
E-mail: kr@aiidatapro.com
http://www.see-news.com


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Query runs very slowly in Postgres, but very fast in other DBMS
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Update aborted if trigger function fails?