X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B2362528B3 for ; Thu, 4 Aug 2005 19:43:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83408-08 for ; Thu, 4 Aug 2005 22:42:59 +0000 (GMT) Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) by svr1.postgresql.org (Postfix) with ESMTP id 713F25282F for ; Thu, 4 Aug 2005 19:42:58 -0300 (ADT) Received: from juju.arbash-meinel.com ([12.214.18.81]) by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP id <20050804224259m92009ipade>; Thu, 4 Aug 2005 22:42:59 +0000 Received: by juju.arbash-meinel.com (Postfix, from userid 505) id 26B8F56051; Thu, 4 Aug 2005 17:42:59 -0500 (CDT) Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) by juju.arbash-meinel.com (Postfix) with ESMTP id 81F4F56016; Thu, 4 Aug 2005 17:42:53 -0500 (CDT) Message-ID: <42F299EC.8080809@arbash-meinel.com> Date: Thu, 04 Aug 2005 17:42:52 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Matthew Schumacher Cc: pgsql-performance@postgresql.org Subject: Re: Performance problems testing with Spamassassin 3.1.0 References: <42E9749F.6000709@aptalaska.net> <1122616211.5691.340.camel@lamb.mcmillan.net.nz> <42EA6966.8090402@aptalaska.net> <1122668371.5691.352.camel@lamb.mcmillan.net.nz> <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> <27897.1122748133@sss.pgh.pa.us> <42EE8043.1050207@aptalaska.net> <42EE93F8.5010003@aptalaska.net> <20050801214931.GF60019@decibel.org> <42EE9D83.8000405@pobox.com> <42F1CE43.8040801@aptalaska.net> <15610.1123166222@sss.pgh.pa.us> <42F23FB6.5010405@aptalaska.net> <42F251F0.1070407@aptalaska.net> <42F26E2C.8010607@arbash-meinel.com> <42F298B5.5010405@aptalaska.net> In-Reply-To: <42F298B5.5010405@aptalaska.net> X-Enigmail-Version: 0.92.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig30078318CC01CA21BF5E0E03" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.045 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200508/45 X-Sequence-Number: 13792 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig30078318CC01CA21BF5E0E03 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Matthew Schumacher wrote: > John A Meinel wrote: > > >>Surely this isn't what you have. You have *no* loop here, and you have >>stuff like: >> AND >> (bayes_token_tmp) NOT IN (SELECT token FROM bayes_token); >> >>I'm guessing this isn't your last version of the function. >> >>As far as putting the CREATE TEMP TABLE inside the function, I think the >>problem is that the first time it runs, it compiles the function, and >>when it gets to the UPDATE/INSERT with the temporary table name, at >>compile time it hard-codes that table id. >> >>I tried getting around it by using "EXECUTE" which worked, but it made >>the function horribly slow. So I don't recommend it. >> >>Anyway, if you want us to evaluate it, you really need to send us the >>real final function. >> >>John >>=:-> > > > It is the final function. It doesn't need a loop because of the > bayes_token_tmp function I added. The array is passed to it and it > returns a record set so I can work off of it like it's a table. So the > function works the same way it before, but instead of using SELECT > intoken from TEMPTABLE, you use SELECT bayes_token_tmp from > bayes_token_tmp(intokenary). > > I think this is more efficient than the create table overhead, > especially because the incoming record set won't be to big. > > Thanks, > > schu > > Well, I would at least recommend that you change the "WHERE bayes_token_tmp NOT IN (SELECT token FROM bayes_token)" with a "WHERE NOT EXISTS (SELECT toke FROM bayes_token WHERE token=bayes_token_tmp)" You might try experimenting with the differences, but on my system the NOT IN has to do a full sequential scan on bayes_token and load all entries into a list, while NOT EXISTS can do effectively a nested loop. The nested loop requires that there is an index on bayes_token(token), but I'm pretty sure there is anyway. Again, in my testing, it was a difference of 4200ms versus 180ms. (800k rows in my big table, 2k in the temp one) John =:-> --------------enig30078318CC01CA21BF5E0E03 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Darwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFC8pnsJdeBCYSNAAMRApkHAKCXHa4ddIXDqGJRk4y9CRLeeEVjOACfcIqh FmYng0yOyadGlXkBQRAgH/E= =mZVF -----END PGP SIGNATURE----- --------------enig30078318CC01CA21BF5E0E03--