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 7C2943A5921 for ; Wed, 26 Jan 2005 15:46:58 +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 33903-08 for ; Wed, 26 Jan 2005 15:46:51 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 14ECA3A516B for ; Wed, 26 Jan 2005 15:46:54 +0000 (GMT) Received: (qmail 26402 invoked from network); 26 Jan 2005 14:00:29 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by 82.67.9.10 with SMTP; 26 Jan 2005 14:00:29 +0100 To: "Greg Stark" , "Merlin Moncure" Cc: "Andrei Bintintan" , pgsql-performance@postgresql.org Subject: Re: [SQL] OFFSET impact on Performance??? References: <6EE64EF3AB31D5448D0007DD34EEB3412A75CB@Herge.rcsinc.local> <87brbiah0f.fsf@stark.xeocode.com> Message-ID: Date: Wed, 26 Jan 2005 13:58:18 +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: <87brbiah0f.fsf@stark.xeocode.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.015 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200501/501 X-Sequence-Number: 10191 Supposing your searches display results which are rows coming from one specific table, you could create a cache table : search_id serial primary key index_n position of this result in the global result set result_id id of the resulting row. Then, making a search with 50k results would INSERT INTO cache ... SELECT FROM search query, with a way to set the index_n column, which can be a temporary sequence... Then to display your pages, SELECT from your table with index_n BETWEEN so and so, and join to the data table. If you're worried that it might take up too much space : store an integer array of result_id instead of just a result_id ; this way you insert fewer rows and save on disk space. Generate it with a custom aggregate... then just grab a row from this table, it contains all the id's of the rows to display.