Re: int8, primary key, seq scan

Поиск
Список
Период
Сортировка
От Dave Cramer
Тема Re: int8, primary key, seq scan
Дата
Msg-id 1092963062.1546.663.camel@localhost.localdomain
обсуждение исходный текст
Ответ на int8, primary key, seq scan  (Jeff Amiel <jamiel@istreamimaging.com>)
Список pgsql-general
This is a known issues with pre 8.0 postgresql...

Dave
On Thu, 2004-08-19 at 17:01, Jeff Amiel wrote:
> 7.4.2 running on FreeBSD 5.4.2
>
> I have a table (called "draft" ) that has a bigserial as the primary key.
>
> "check_id bigserial NOT NULL"
>
> I  do NOT have an additional index on that column.
>
> I have a plpgsql function (stored procedure) that selects from that
> table based on the primary key field
>
> "select into draftrow * from draft where check_id=draftid;"
> where draft id is declared in the DECLARE section as "draftid int8;"
>
> This query is woefully slow.  Sequential scan on table
>
> However, if I modify the query as follows:
>
> "select into draftrow * from draft where check_id=int8(draftid);"
>
> Ultra mega speed improvement. Index scan using the primary key.
>
> I declared the compared value (draftid) as an int8, why should I have to
> cast it as such in the query to cause the optimizer to use the primary key?
>
>
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
--
Dave Cramer
519 939 0336
ICQ # 14675561
www.postgresintl.com


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

Предыдущее
От: Robby Russell
Дата:
Сообщение: Re: Postgresql feature
Следующее
От: Tom Lane
Дата:
Сообщение: Re: function runs on Windows not on solaris