pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Edoardo Ceccarelli <eddy@axa.it>
To: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Cc: Nick Barr <nicky@chuckie.co.uk>
Cc: pgsql-performance@postgresql.org
Subject: Re: slow seqscan
Date: Wed, 21 Apr 2004 11:41:11 +0200
Message-ID: <408641B7.5090808@axa.it> (raw)
In-Reply-To: <408636A5.2050305@familyhealth.com.au>
References: <40862003.2090201@axa.it>
	<4086272E.2080102@chuckie.co.uk>
	<40863228.907@axa.it>
	<408636A5.2050305@familyhealth.com.au>


> What happens if you go:
>
> CREATE INDEX annuncio400_rubric_testo_idx ON annuncio400(rubric, 
> LOWER(testo));
>
> or even just:
>
> CREATE INDEX annuncio400_rubric_testo_idx ON annuncio400(LOWER(testo));
>
I wasn't able to make this 2 field index with lower:

dba400=# CREATE INDEX annuncio400_rubric_testo_idx ON 
annuncio400(rubric, LOWER(testo));
ERROR:  parser: parse error at or near "(" at character 71

seems impossible to creat 2 field indexes with lower function.

The other one does not make it use the index.


>> But the strangest thing ever is that if I change the filter with 
>> another one that represent a smaller amount of data  it uses the 
>> index scan!!!
>
>
> What's strange about that?  The less data is going to be retrieved, 
> the more likely postgres is to use the index.
>
can't understand this policy:

dba400=# SELECT count(*) from annuncio400 where rubric='DD';
 count
-------
  6753
(1 row)

dba400=# SELECT count(*) from annuncio400 where rubric='MA';
 count
-------
  2165
(1 row)

so it's using the index on 2000 rows and not for 6000?  it's not that 
big difference, isn't it?


> I suggest maybe increasing the amount of stats recorded for your 
> rubrik column:
>
> ALTER TABLE annuncio400 ALTER rubrik SET STATISTICS 100;
> ANALYZE annuncio400;
>
done, almost the same, still not using index

> You could also try reducing the random_page_cost value in your 
> postgresql.conf a little, say to 3 (if it's currently 4).  That will 
> make postgres more likely to use index scans over seq scans.
>

changed the setting on postgresql.conf, restarted the server,
nothing has changed.

what about setting this to false?
#enable_seqscan = true

thanks again
Edoardo



view thread (12+ messages)  latest in thread

Message-ID: <408641B7.5090808@axa.it>
Permalink:  ../408641B7.5090808@axa.it/
Also on:    postgresql.org/message-id/408641B7.5090808@axa.it

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: eddy@axa.it, chriskl@familyhealth.com.au, nicky@chuckie.co.uk
  Subject: Re: slow seqscan
  In-Reply-To: <408641B7.5090808@axa.it>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox