Re: estimated rows vs. actual rows - Mailing list pgsql-performance

From Josh Berkus
Subject Re: estimated rows vs. actual rows
Date
Msg-id 200502131341.09811.josh@agliodbs.com
Whole thread Raw
In response to estimated rows vs. actual rows  (Jaime Casanova <systemguards@gmail.com>)
Responses Re: estimated rows vs. actual rows
List pgsql-performance
Jaime,

> Why is this query using a seq scan rather than a index scan?

Because it thinks a seq scan will be faster.

> i notice
> the diff between the estimated rows and actual rows (almost 2000).

Yes, ANALYZE, and possibly increasing the column stats, should help that.

> Can this affect the query plan? i think this is a problem of
> statistics, am i right? if so, what can be done?

Well, if the estimate was accurate, PG would be even *more* likely to use a
seq scan (more rows).

I think maybe you should establish whether a seq scan actually *is* faster?
Perhaps do SET enable_seqscan = false and then re-run the query a few times?

--
Josh Berkus
Aglio Database Solutions
San Francisco

pgsql-performance by date:

Previous
From: Jaime Casanova
Date:
Subject: estimated rows vs. actual rows
Next
From: Jaime Casanova
Date:
Subject: Re: estimated rows vs. actual rows