X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (developer.postgresql.org [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 1A011B439AF for ; Tue, 8 Jul 2003 23:51:19 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 09213-04 for ; Tue, 8 Jul 2003 20:50:47 -0300 (ADT) Received: from water.oasis.net.au (water.oasis.net.au [210.8.139.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9F21FB435E9 for ; Tue, 8 Jul 2003 20:50:45 -0300 (ADT) Received: from oasis.net.au (guardian [210.8.139.5]) by water.oasis.net.au (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id KAA10719 for ; Wed, 9 Jul 2003 10:09:39 +1000 X-Authentication-Warning: water.oasis.net.au: Host guardian [210.8.139.5] claimed to be oasis.net.au Message-ID: <3F0B5927.5070705@oasis.net.au> Date: Wed, 09 Jul 2003 09:52:07 +1000 From: Rudi Starcevic User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Logging select statements Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/92 X-Sequence-Number: 14206 Hi, I have an application where user's can view records in a short form with their first select and view a long form with a second select. The first view I term an impression. The second view I term a click. I'd like to log the impression's and click's. I'm wondering which is the most effiecient way to do this. I know I can do it in the application, PHP, by looping through the result set and inserting into a logging table but am wondering if it quicker to write a rule or trigger so that each individual select is logged into a logging table as it's selected. For example: If I have a table of 3000 row's and the user submits a query which retrieve's 100 rows. In the first senario I could loop through the 100, using a language PHP or Perl, and make 100 inserts after the first select is complete. Thus 1 select plus 100 inserts. Can you see a way to do this all in SQL that would be better/faster/more efficient without using PHP/Perl ? Many thanks Regards Rudi.