Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:22603 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59880 invoked by uid 1010); 28 Mar 2006 00:20:15 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 59865 invoked from network); 28 Mar 2006 00:20:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Mar 2006 00:20:15 -0000 X-Host-Fingerprint: 219.166.150.11 mx1.es-i.jp Linux 2.4 w/o timestamps Received: from ([219.166.150.11:47311] helo=mx1.es-i.jp) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id ED/B1-37235-E3188244 for ; Mon, 27 Mar 2006 19:20:14 -0500 Received: (qmail 3193 invoked by uid 501); 28 Mar 2006 00:20:11 -0000 Received: from yohgaki@ohgaki.net by mx1.es-i.jp by uid 401 with qmail-scanner-1.20 (clamscan: 0.65. spamassassin: 2.60. Clear:RC:1(192.168.100.210):. Processed in 0.014792 secs); 28 Mar 2006 00:20:11 -0000 X-Qmail-Scanner-Mail-From: yohgaki@ohgaki.net via mx1.es-i.jp X-Qmail-Scanner: 1.20 (Clear:RC:1(192.168.100.210):. Processed in 0.014792 secs) Received: from unknown (HELO ?127.0.0.1?) (192.168.100.210) by mx1.es-i.jp with SMTP; 28 Mar 2006 00:20:10 -0000 Message-ID: <442881AC.9080304@ohgaki.net> Date: Tue, 28 Mar 2006 09:22:04 +0900 User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: Lukas Smith CC: internals@lists.php.net References: <4425040E.60402@ohgaki.net> <44250532.7070509@php.net> <44275330.7050508@ohgaki.net> <44279BCB.1090105@php.net> <44280F96.3090600@ohgaki.net> <44281210.3000103@php.net> <442816CF.6040305@ohgaki.net> <442817F7.1080409@php.net> In-Reply-To: <442817F7.1080409@php.net> X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: pg_execute error From: yohgaki@ohgaki.net (Yasuo Ohgaki) Lukas Smith wrote: > Yasuo Ohgaki wrote: > >> @ operator is ok, but usually @ operator is not recommenned. >> Don't you think so? I try not to use @ as much as possible. >> >> pg_execute() does not have to raise error just like file_exists(). >> It may be good idea to raise error when connection is bad, etc. > > the problem is a limitation in pgsql and hiding this fact imho causes > more problems than it solves, especially since pgsql will eventually > solve this limitation (i hear 8.2 will solve this). I heard postgresql people intends just execute PQexecute, if it fails, prepare since this is most natural way to handle persistent database connections. 8.2 backends will have view for currently registered plans. Since backends have query plans, clients must requests send over net work just to see if plan is defined or not. i.e. if (!pg_execute('plan')) { pg_prepare('plan', sql); pg_execute('plan'); } Looking up plan data in backends is just a waste of resources even when 8.2 is available. > > another solution that does of course add a fixed amount of overhead is > to simply prepare the statement again before you enter the loop. you > will then only have to supress a single call to pg_prepare(). pg_prepare() also raises E_WARNING when plan is already defined, thus calling pg_prepare() is not an option. PQprepare is not light function also. It has to initialize SQL parser etc, while PQexecute just looks up plan names when it fails. When app uses PHP's persistent connections (or pgpooled connections), programmers can take advantages of prepared statements performance benefits. i.e. PostgreSQL have to compile SQL only once for a web server thread /process. I don't see any down sides removing pg_execute E_WARNING for duplicate plans. I will restore pg_execute E_WARING except already defined plans. Is this satisfactory? -- Yasuo Ohgaki