pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ivan Voras <ivoras@freebsd.org>
To: pgsql-performance@postgresql.org
Subject: Re: Understanding tsearch2 performance
Date: Wed, 14 Jul 2010 15:57:35 +0200
Message-ID: <i1kfnt$5mh$1@dough.gmane.org> (raw)
In-Reply-To: <20100714134928.GL21875@tamriel.snowman.net>
References: <i1k84l$984$1@dough.gmane.org>
	<Pine.LNX.4.64.1007141629000.32129@sn.sai.msu.ru>
	<i1kc3m$ngr$1@dough.gmane.org>
	<Pine.LNX.4.64.1007141722480.32129@sn.sai.msu.ru>
	<i1kej2$12t$1@dough.gmane.org>
	<20100714134928.GL21875@tamriel.snowman.net>

On 07/14/10 15:49, Stephen Frost wrote:
> * Ivan Voras (ivoras@freebsd.org) wrote:
>>  Total runtime: 0.507 ms
> [...]
>>  Total runtime: 118.689 ms
>>
>> See in the first query where I have a simple LIMIT, it fetches random 10
>> rows quickly, but in the second one, as soon as I give it to execute and
>> calculate the entire result set before I limit it, the performance is
>> horrible.
> 
> What you've shown is that it takes 0.5ms for 10 rows, and 118ms for 8500
> rows.

Yes, but...

>  Now, maybe I've missed something, but that's 0.05ms per row for
> the first query and 0.01ms per row for the second, and you've added a
> sort into the mix.  The performance of going through the data actually
> improves on a per-record basis, since you're doing more in bulk.
> 
> Since you're ordering by 'id', PG has to look at every row returned by
> the index scan.  That's not free.

This part of the processing is going on on the backend, and the backend
needs to sort through 8500 integers. I don't think the sort is
significant here.

> Regarding the statistics, it's entirely possible that the index is *not*
> the fastest way to pull this data (it's nearly 10% of the table..), if
> the stats were better it might use a seq scan instead, not sure how bad
> the cost of the filter itself would be.

I think that what I'm asking here is: is it reasonable for tsearch2 to
extract 8,500 rows from an index of 90,000 rows in 118 ms, given that
the approximately same task can be done with an unindexed "LIKE"
operator in nearly the same time?





view thread (12+ messages)  latest in thread

Message-ID: <i1kfnt$5mh$1@dough.gmane.org>
Permalink:  ../i1kfnt$5mh$1@dough.gmane.org/
Also on:    postgresql.org/message-id/i1kfnt$5mh$1@dough.gmane.org

 · 

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: ivoras@freebsd.org
  Subject: Re: Understanding tsearch2 performance
  In-Reply-To: <i1kfnt$5mh$1@dough.gmane.org>

* 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