pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jerry Wintrode <wintrojr@tripos.com>
To: pgsql-sql@postgresql.org
Subject: Re: Need another way to do this, my sql much to slow...
Date: Thu, 20 Nov 2003 17:26:00 -0600
Message-ID: <4E676B0AAF74B443A18D7BC7AAB3CFFD1D44D8@s01-exch01.tripos.com> (raw)



Ok, I figured that part out by simply changing the way I'm doing to
query, and writing a function to handle the reply. But it will introduce
another problem. How to I pass special characters, any character, to a
function like this:

select msg_2_env('"Ann's Free Gifts & Coupons"
<server1@mail03a-free-gifts.mx07.com>');

As you can see the message from name is:
"Ann's Free Gifts & Coupons" server1@mail03a-free-gifts.mx07.com

I need that whole string to match. Including the ",&,@, and yes the
single quote in Ann's. Passed as a variable this should not be a
problem, I think, but how do I test this on the command line with psql?

Oh, here is the simple function in case anyone cares to have it...very
simple. Now processing about 100000 records takes 1ms. Down from the
12-15 seconds. WooHoo. Just that other little issue..hehehe.

========================================================================
====
CREATE FUNCTION msg_2_env (text) RETURNS int4 AS
'
    DECLARE
        intext ALIAS FOR $1;
        result int4;

    BEGIN

        result := ( SELECT count(DISTINCT
record_of_claims.msg_sender_num) AS mclaim_count FROM record_of_claims
WHERE (record_of_claims.env_sender_num = (SELECT
env_from_senders.env_sender_num FROM env_from_senders WHERE
(env_from_senders.envelope_from = intext::character varying))) GROUP BY
record_of_claims.env_sender_num );

        RETURN result;

    END;
' LANGUAGE 'plpgsql';

========================================================================
====

Jerry Wintrode
Network Administrator
Tripos, Inc.





---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend





view thread (5+ messages)  latest in thread

Message-ID: <4E676B0AAF74B443A18D7BC7AAB3CFFD1D44D8@s01-exch01.tripos.com>
Permalink:  ../4E676B0AAF74B443A18D7BC7AAB3CFFD1D44D8@s01-exch01.tripos.com/
Also on:    postgresql.org/message-id/4E676B0AAF74B443A18D7BC7AAB3CFFD1D44D8@s01-exch01.tripos.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: wintrojr@tripos.com
  Subject: Re: Need another way to do this, my sql much to slow...
  In-Reply-To: <4E676B0AAF74B443A18D7BC7AAB3CFFD1D44D8@s01-exch01.tripos.com>
  References: <4E676B0AAF74B443A18D7BC7AAB3CFFD1D44D8@s01-exch01.tripos.com>

* 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