Re: Query using SeqScan instead of IndexScan

From: Jim Nasby <jnasby(at)pervasive(dot)com>
To: Brendan Duddridge <brendan(at)clickspace(dot)com>
Cc: chris smith <dmagick(at)gmail(dot)com>, PostgreSQL Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Query using SeqScan instead of IndexScan
Date: 2006-04-04 20:28:24
Message-ID: B35559FB-1012-4C9A-811B-0F1D37462F34@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Apr 1, 2006, at 12:51 PM, Brendan Duddridge wrote:
> from SELECT * FROM pg_stats WHERE tablename='table' AND
> attname='category_id'
>
> I find correlation on category_product for category_id is 0.643703
>
> Would setting the index on category_id to be clustered help with this?

It would absolutely help on the query in question. In my experience,
a correlation of 0.64 is too low to allow an index scan to be used
for anything but a tiny number of rows.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Mike Quinn 2006-04-04 22:07:25 Re: The order of fields around the "=" in the WHERE
Previous Message Jim Nasby 2006-04-04 20:26:37 Re: Query using SeqScan instead of IndexScan