Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id F37E12E30EC for ; Sun, 13 Jan 2008 23:40:03 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 08013-01 for ; Sun, 13 Jan 2008 23:40:01 -0400 (AST) Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.181]) by postgresql.org (Postfix) with ESMTP id CE9432E30D3 for ; Sun, 13 Jan 2008 23:40:00 -0400 (AST) Received: by wa-out-1112.google.com with SMTP id m38so3670755waf.5 for ; Sun, 13 Jan 2008 19:39:59 -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:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=1lKz8e4RqET9qugWrlpJl+/4Mcw5/ZP5dZSuYcYFiOI=; b=QN3w+uQMwIIjs0dK+sODMmK1ZHqqGMlAS6FCqJSJGPhi+IbobIqsvne9RTibxiIYs1FTAtIzrJCcMqjwLuSu5d4NwnW/jzUDHEsgGhbv5VeiUk4nfF24urczmMOZX//fHK/CF7PEALgNKACTq8MWu0qOGDX4WvkYmCqAgnwbBBE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=i0W7RevqE5gE5juHt8CvKl2DHdl+mrdn+jBNMGj1GiMAUmkiQ9oQDqDMa33MFIzKonjtYnHIF0DLA1wg4yYP6rYCIPqylY+nyeW9fYC12UrZFeAELFIXjzEMQ8LfcLjcuuK1UJCIzgu6rEURnhC9wUElAOzWS4p4iseLWfjJpQ0= Received: by 10.115.107.1 with SMTP id j1mr2534980wam.55.1200281999104; Sun, 13 Jan 2008 19:39:59 -0800 (PST) Received: by 10.114.131.4 with HTTP; Sun, 13 Jan 2008 19:39:59 -0800 (PST) Message-ID: Date: Sun, 13 Jan 2008 21:39:59 -0600 From: "Scott Marlowe" To: "pepone. onrez" Subject: Re: query performance Cc: pgsql-general@postgresql.org In-Reply-To: <198501d60801131858n529b46dcmeb286cda32d56e93@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <198501d60801131858n529b46dcmeb286cda32d56e93@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/622 X-Sequence-Number: 126830 On Jan 13, 2008 8:58 PM, 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 > > here is the explain output > > "Limit (cost= 100058762.30..100058799.02 rows=50 width=58) (actual > time=19433.474..19433.680 rows=50 loops=1)" > " -> Seq Scan on t_documentcontent (cost=100000000.00..100110772.07 > rows=150807 width=58) (actual time=53.934..19402.030 rows=80050 loops=1)" > "Total runtime: 19433.748 ms" looks like you've set enable_seqscan=off. When looking for help on queries it's a good idea to mention such things... with no order by, and possibly no index on t_documentcontent._id, there's no choice but a seq scan. try adding both.