Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 406AF9FB79D for ; Thu, 31 May 2007 05:42:05 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 57910-08 for ; Thu, 31 May 2007 05:41:59 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from web52708.mail.re2.yahoo.com (web52708.mail.re2.yahoo.com [206.190.48.231]) by postgresql.org (Postfix) with SMTP id E7F4D9FB6E9 for ; Thu, 31 May 2007 05:42:01 -0300 (ADT) Received: (qmail 84732 invoked by uid 60001); 31 May 2007 08:42:00 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Message-ID; b=tqCtNedrD3rmGmZC43hEB0nEcP/FbzcTkwt1aGm3pAvMf1uhOSXlZMF8bwV0hkgn7GPTKDZ9SITdbez/votj2DFFUQNk9/cbK0uz5JuCk+0NvPThApAjm71YHvZ6S7HvHLmoVDcj+BZ5WAf4TcZFUfVWjqqRCZduch0VOjZ/02o=; X-YMail-OSG: LkxVPjIVM1nuz6V_FsqzBF7X1ku9KpUPotCuptzq8vmddSv.xcPtWz69qL7qipgSJaWmOmvykxC1DRY9rqjuvRK7_6NwXZv47NkDXonTzwazVy40FEza9MXkGSaE0A-- Received: from [195.168.227.227] by web52708.mail.re2.yahoo.com via HTTP; Thu, 31 May 2007 01:42:00 PDT X-Mailer: YahooMailRC/651.23.1 YahooMailWebService/0.7.41.14 Date: Thu, 31 May 2007 01:42:00 -0700 (PDT) From: Trigve Siver Subject: Re: slow query execution To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Message-ID: <620846.83344.qm@web52708.mail.re2.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.055 tagged_above=0 required=5 tests=AWL=-0.301, BAYES_50=0.001, DNS_FROM_RFC_ABUSE=0.2, DNS_FROM_RFC_POST=1.708, DNS_FROM_RFC_WHOIS=1.447 X-Spam-Level: *** X-Archive-Number: 200705/208 X-Sequence-Number: 28488 Thanks for reply, This solution looks promising. I'll look at it and test it and let you know. Thanks once more Trigve ----- Original Message ---- From: Richard Huxton To: Trigve Siver Sent: Thursday, May 31, 2007 10:33:40 AM Subject: Re: [SQL] slow query execution Trigve Siver wrote: > Hi, thanks for reply > > No, I'm working with c++ and libpqxx (pgsql c++ binding). I'm using > Win32 Listview control with LS_OWNERDATA style. I can use std::map to > map row_number to ID field but then I must fetch all records from > that table. This could be ineffective when table has about 10.000+ > records and user want to view/search only first 100 records. So - you want something like: The user runs a query ("all blue things") and that gives a list of results. They can then filter those results further ("shape=round") and you want to highlight those elements that match. You either can't or don't want to filter in the application, rather you would like to run this as two queries but need to match up results from the second query with the first query (your list). Suggestion: For the first query, make sure you have the relevant primary key columns in your query and do: CREATE TEMPORARY TABLE my_results AS SELECT ... Then, you can join against that table in the second query. The temporary table will exist until you disconnect - see CREATE TABLE for details. -- Richard Huxton Archonet Ltd ____________________________________________________________________________________Ready for the edge of your seat? Check out tonight's top picks on Yahoo! TV. http://tv.yahoo.com/