Skip site navigation (1) Skip section navigation (2)

Re: same question little different test MSSQL vrs Postgres

From: Greg Stark <gsstark(at)mit(dot)edu>
To: "Joel Fradkin" <jfradkin(at)wazagua(dot)com>
Cc: "'Richard Huxton'" <dev(at)archonet(dot)com>, <gsstark(at)mit(dot)edu>,<pgsql-sql(at)postgresql(dot)org>, <ac(at)wazagua(dot)com>,"Steve Goldsmith" <SGoldsmith(at)fcci-group(dot)com>
Subject: Re: same question little different test MSSQL vrs Postgres
Date: 2005-01-26 16:50:06
Message-ID: 87r7k8yw1t.fsf@stark.xeocode.com (view raw or flat)
Thread:
Lists: pgsql-sql
"Joel Fradkin" <jfradkin(at)wazagua(dot)com> writes:

> I tried the SET ENABLE_SEQSCAN=FALSE;
> And the result took 29 secs instead of 117.
> 
> After playing around with the cache and buffers etc I see I am no longer
> doing any swapping (not sure how I got the 100 sec response might have been
> shared buffers set higher, been goofing around with it all morning).

If it's swapping you're definitely going to get bad results. You really want
the *majority* of RAM left free for the OS to cache disk data.

> My worry here is it should obviously use an index scan so something is not
> setup correctly yet. I don't want to second guess the analyzer (or is this a
> normal thing?)

No that's not obvious. 22k out of 344k is a selectivity of 6.6% which is
probably about borderline. The optimizer is estimating even worse at 10.9%
which isn't far off but puts it well out of the range for an index scan.

If you really want to get postgres using an index scan you'll have to a)
improve the estimate using "alter table tblcase alter column clientnum set
statistics" to raise the statistics target for that column and reanalyze. 

And b) lower random_page_cost. random_page_cost tells postgres how much slower
indexes are than table scans and at the default setting it accurately
represents most disk hardware. If your database fits within RAM and is often
cached then you might have to lower it to model that fact. But you shouldn't
do it based on a single query like this.


-- 
greg


In response to

Responses

pgsql-sql by date

Next:From: Joel FradkinDate: 2005-01-26 17:04:07
Subject: Re: same question little different test MSSQL vrs Postgres
Previous:From: Joel FradkinDate: 2005-01-26 16:31:32
Subject: Re: same question little different test MSSQL vrs Postgres

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group