Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id AFE742E3693 for ; Mon, 14 Jan 2008 00:27:34 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 02731-07 for ; Mon, 14 Jan 2008 00:27:31 -0400 (AST) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.241]) by postgresql.org (Postfix) with ESMTP id 963B52E33A8 for ; Mon, 14 Jan 2008 00:27:31 -0400 (AST) Received: by an-out-0708.google.com with SMTP id c36so441160ana.33 for ; Sun, 13 Jan 2008 20:27:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=zLaNNePQ8W5kY10HlEbo79uFL9ULZfKl43ORWFhdNpU=; b=TGfg/tgSzfKZk6kuFyI+5/UKTQCydNeCwHj8qyXKO5/gPLyMPWF1WJ8+QC1zh8taKJ8zTZY0lBvbRSgMzND+WOEG7SLETkMvG6jFxyCSMRj7piiUZezcClL3RnMP72YZ+iGIy9FTfrOPSGlFppe/tUX6mCP6BpYobK7kX0OF/WI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=bh0gVx1HOOuTJk/RchHL41KdHNBA86iQq3MAwkDRO7axE+TpJXMtg6LuIL9XMxJ94uLoitm/FjTBQQVLj/XeufOtQIdjFMK6/8xYxsMsMz5iCIt1UMQiW9D+m5TrDSnIDgN71WkgJ8lNq6Ou43iSgc4Jk+Y8J6QC8bk1mRxal3Y= Received: by 10.100.128.20 with SMTP id a20mr13072572and.109.1200284851112; Sun, 13 Jan 2008 20:27:31 -0800 (PST) Received: by 10.100.93.16 with HTTP; Sun, 13 Jan 2008 20:27:31 -0800 (PST) Message-ID: <198501d60801132027h1201ba2dk6f596576ae9e48df@mail.gmail.com> Date: Mon, 14 Jan 2008 05:27:31 +0100 From: pepone.onrez To: pgsql-general Subject: Re: query performance In-Reply-To: <18894.1200282745@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_8687_7519756.1200284851107" References: <198501d60801131858n529b46dcmeb286cda32d56e93@mail.gmail.com> <18894.1200282745@sss.pgh.pa.us> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/624 X-Sequence-Number: 126832 ------=_Part_8687_7519756.1200284851107 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Sorry Alex i forget mention that i have setscan of in my last test. now I have set seqscan on and indexscan on and added order by _id The table has an index in the _id field CREATE INDEX i_documentcontent_document ON t_documentcontent USING btree (_document); The database was rencently vacum analyze , but not vacun full here is the explain of 2 diferent queries , when i put a large OFFSET EXPLAIN ANALYZE SELECT t_documentcontent._id AS _id FROM t_documentcontent ORDER BY _id LIMIT 50 OFFSET 50000 "Limit (cost=137068.24..137068.36 rows=50 width=58) (actual time= 41119.702..41119.792 rows=50 loops=1)" " -> Sort (cost=136943.24..137320.26 rows=150807 width=58) (actual time= 41064.802..41100.424 rows=50050 loops=1)" " Sort Key: _id" " -> Seq Scan on t_documentcontent (cost= 0.00..110772.07rows=150807 width=58) (actual time= 106.679..33267.194 rows=150807 loops=1)" "Total runtime: 41120.015 ms" EXPLAIN ANALYZE SELECT t_documentcontent._id AS _id FROM t_documentcontent ORDER BY _id LIMIT 50 OFFSET 10000 "Limit (cost=39839.37..40038.56 rows=50 width=58) (actual time= 1172.969..1194.228 rows=50 loops=1)" " -> Index Scan using i_documentcontent_id on t_documentcontent (cost= 0.00..600805.54 rows=150807 width=58) (actual time= 0.077..1189.688rows=10050 loops=1)" "Total runtime: 1194.316 ms" Tom i using uuid for the _id field that is the primary key add a WHERE id > ? don 't apply the cursor aproach is also not suitable for same of my queries I use this query for paginate contents of a filesysstem with lots of documents avoid offset is not posible always ------=_Part_8687_7519756.1200284851107 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Sorry Alex i forget mention that i have setscan of in my last test.

now I have set seqscan on  and indexscan on and added order by _id 

The table has an index in the _id field 

CREATE INDEX i_documentcontent_document
  ON t_documentcontent
  USING btree
  (_document);

The database was rencently vacum analyze , but not vacun full

here is the explain of 2 diferent queries , when i put a large OFFSET

 EXPLAIN ANALYZE SELECT

    t_documentcontent._id AS _id
    FROM t_documentcontent ORDER BY _id LIMIT 50 OFFSET 50000

"Limit  (cost=137068.24..137068.36 rows=50 width=58) (actual time=41119.702..41119.792 rows=50 loops=1)"
"  ->  Sort  (cost=136943.24..137320.26 rows=150807 width=58) (actual time=41064.802..41100.424 rows=50050 loops=1)"
"        Sort Key: _id"
"        ->  Seq Scan on t_documentcontent  (cost= 0.00..110772.07 rows=150807 width=58) (actual time=106.679..33267.194 rows=150807 loops=1)"
"Total runtime: 41120.015 ms"

 EXPLAIN ANALYZE SELECT

    t_documentcontent._id AS _id
    FROM t_documentcontent ORDER BY _id LIMIT 50 OFFSET 10000

"Limit  (cost=39839.37..40038.56 rows=50 width=58) (actual time=1172.969..1194.228 rows=50 loops=1)"
"  ->  Index Scan using i_documentcontent_id on t_documentcontent  (cost=0.00..600805.54 rows=150807 width=58) (actual time= 0.077..1189.688 rows=10050 loops=1)"
"Total runtime: 1194.316 ms"

Tom
 i using uuid for the _id field that is the primary key  add a WHERE id > ?  don 't apply
the cursor aproach is also not suitable for same of my queries

I use this query for paginate contents of a filesysstem with lots of documents avoid offset is not posible always ------=_Part_8687_7519756.1200284851107--