Re: Optimizer not using index on 120M row table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jim(at)nasby(dot)net
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Optimizer not using index on 120M row table
Date: 2003-04-08 03:51:17
Message-ID: 24163.1049773877@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Jim C. Nasby" <jim(at)nasby(dot)net> writes:
> project_id | smallint | not null

> explain select * from email_contrib where project_id=8 and id=39622 and
> date='3/1/03';

Cast the constants to smallint, eg

project_id = 8::smallint and ...

or quote them if that feels cleaner to you:

project_id = '8' and ...

or just declare project_id to be integer (hint: the space savings are
completely illusory in this example, anyway, because of alignment
requirements).

See the archives for much prior discussion ;-)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jim C. Nasby 2003-04-08 03:54:21 Re: Optimizer not using index on 120M row table
Previous Message Nikolaus Dilger 2003-04-08 03:50:42 Re: Trying to Tunning DB