pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rudi Starcevic <rudi@oasis.net.au>
To: pgsql-sql@postgresql.org
Subject: Logging select statements
Date: Wed, 09 Jul 2003 09:52:07 +1000
Message-ID: <3F0B5927.5070705@oasis.net.au> (raw)

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.











view thread (7+ messages)  latest in thread

Message-ID: <3F0B5927.5070705@oasis.net.au>
Permalink:  ../3F0B5927.5070705@oasis.net.au/
Also on:    postgresql.org/message-id/3F0B5927.5070705@oasis.net.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rudi@oasis.net.au
  Subject: Re: Logging select statements
  In-Reply-To: <3F0B5927.5070705@oasis.net.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox