Re: query performance - Mailing list pgsql-general

From Alban Hertroys
Subject Re: query performance
Date
Msg-id 46940304-080A-441E-B070-C665102CCC0C@solfertje.student.utwente.nl
Whole thread Raw
In response to query performance  (pepone.onrez <pepone.onrez@gmail.com>)
List pgsql-general
On Jan 14, 2008, at 3:58 AM, pepone.onrez wrote:

> I have this query in a table with 150 thowsand tuples and it takes
> to long
>
>     t_documentcontent._id AS _id
>     FROM t_documentcontent LIMIT 50 OFFSET 80000


You want an ORDER BY there. Not only will it probably speed things
up, without it there's no guaranteed order in the results returned.

As table records have no specific order and updates and inserts on
that table take the first free position, you risk ending up showing
some records twice in your set (same id on different 'pages') and
missing others because you've already skipped past them when there's
concurrent access.

There's still some risk for that if you order, but as you seem to
order on a sequence-generated column, updates aren't a problem for
you and inserts end up at the end anyway. But only if you order them.

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.


!DSPAM:737,478f1e139491365710960!



pgsql-general by date:

Previous
From: "Marc G. Fournier"
Date:
Subject: Re: postgresql in FreeBSD jails: proposal
Next
From: Reg Me Please
Date:
Subject: Accessing composite type columns from C