X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 07681D1D4C7 for ; Thu, 20 Nov 2003 23:27:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 38083-04 for ; Thu, 20 Nov 2003 19:27:23 -0400 (AST) Received: from mailgate.tripos.com (mailgate.tripos.com [192.160.145.7]) by svr1.postgresql.org (Postfix) with ESMTP id E7CD8D1B54C for ; Thu, 20 Nov 2003 19:27:20 -0400 (AST) Message-ID: <4E676B0AAF74B443A18D7BC7AAB3CFFD1D44D8@s01-exch01.tripos.com> From: "Jerry Wintrode" To: Date: Thu, 20 Nov 2003 17:26:00 -0600 Subject: Re: Need another way to do this, my sql much to slow... MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 X-MS-Has-Attach: X-MS-TNEF-Correlator: content-class: urn:content-classes:message Thread-Topic: [SQL] Need another way to do this, my sql much to slow... Thread-Index: AcOvfCWzf9Oa81KGRbqPoLdUuhCNfAABVbRwAA7QYsA= X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/253 X-Sequence-Number: 16068 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" '); 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. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D CREATE FUNCTION msg_2_env (text) RETURNS int4 AS ' DECLARE intext ALIAS FOR $1; result int4; BEGIN result :=3D ( SELECT count(DISTINCT record_of_claims.msg_sender_num) AS mclaim_count FROM record_of_claims WHERE (record_of_claims.env_sender_num =3D (SELECT env_from_senders.env_sender_num FROM env_from_senders WHERE (env_from_senders.envelope_from =3D intext::character varying))) GROUP BY record_of_claims.env_sender_num ); RETURN result; END; ' LANGUAGE 'plpgsql'; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D Jerry Wintrode Network Administrator Tripos, Inc. ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend