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

Re: query very slow when enable_seqscan=on

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Tomasz Ostrowski <tometzky(at)batory(dot)org(dot)pl>
Cc: pgsql-bugs(at)postgresql(dot)org, pgsql-performance(at)postgresql(dot)org
Subject: Re: query very slow when enable_seqscan=on
Date: 2006-07-03 23:05:42
Message-ID: 1151967943.2479.330.camel@localhost.localdomain (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-performance
On Mon, 2006-07-03 at 22:31 +0200, Tomasz Ostrowski wrote:
> I have a very slow query when enable_seqscan=on and very fast when
> enable_seqscan=off. My schema looks like this (relevant columns
> only):
> PS. Actual table and column names are different (they're in Polish)
> but I've translated them for better readability for english-speaking.

Thanks

> PS. I wonder if it makes sense to "enable_seqscan=off" for every client
> if a database is small enough to fit in OS cache.

You can set this for individual statements if you choose to.

>          ->  Seq Scan on organization  (cost=0.00..480.95 rows=1
> width=4) (actual time=0.071..69.702 rows=1892 loops=1)
>                Filter: ((organization_location)::text ~*
> 'warszawa'::text)

The issue is caused by the under-estimation of the number of rows in the
table as a result of the regular expression comparison. As a result the
planner thinks it can choose a nested loops scan, though ends up doing
1892 seq scans of persons, when it thought it would do only one. 

The under estimation is a known issue. Posting to -perform for the
record. 

-- 
  Simon Riggs
  EnterpriseDB          http://www.enterprisedb.com


In response to

pgsql-performance by date

Next:From: Tom LaneDate: 2006-07-03 23:05:46
Subject: Re: query very slow when enable_seqscan=on
Previous:From: Tomasz OstrowskiDate: 2006-07-03 20:31:07
Subject: query very slow when enable_seqscan=on

pgsql-bugs by date

Next:From: Tom LaneDate: 2006-07-03 23:05:46
Subject: Re: query very slow when enable_seqscan=on
Previous:From: Tom LaneDate: 2006-07-03 22:52:59
Subject: Re: BUG #2510: ERROR: out of memory DETAIL: Failed on request of size 825242672.

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