X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A1CC53A5D14 for ; Thu, 27 Jan 2005 09:52:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31635-02 for ; Thu, 27 Jan 2005 09:52:18 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 1193C3A18B7 for ; Thu, 27 Jan 2005 09:52:19 +0000 (GMT) Received: (qmail 8098 invoked from network); 27 Jan 2005 10:52:36 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 27 Jan 2005 10:52:36 +0100 To: alex@neteconomist.com Cc: "Greg Stark" , "Merlin Moncure" , "Andrei Bintintan" , pgsql-performance@postgresql.org Subject: Re: [SQL] OFFSET impact on Performance??? References: <6EE64EF3AB31D5448D0007DD34EEB3412A75CB@Herge.rcsinc.local> <87brbiah0f.fsf@stark.xeocode.com> <33c6269f0501261035bc87695@mail.gmail.com> <33c6269f05012620427c1ccc40@mail.gmail.com> Message-ID: Date: Thu, 27 Jan 2005 10:54:25 +0100 From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <33c6269f05012620427c1ccc40@mail.gmail.com> User-Agent: Opera M2/7.54 (Linux, build 751) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/528 X-Sequence-Number: 10218 > Thats a really good idea, just store a list of the sorted ids in the > temp table - small amount of data for insert... I like it! > > Alex Turner > NetEconomist The best part is that you can skip the LIMIT/OFFSET entirely if you put page numbers in your cache table while inserting into it, via a temporary sequence or something. Retrieving the results will then be very fast, but beware that SELECT * FROM table WHERE id =ANY( array ) won't use an index, so you'll have to trick the thing by generating a query with IN, or joining against a SRF returning the elements of the array one by one, which might be better.