Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101046 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20336 invoked from network); 4 Nov 2017 07:28:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Nov 2017 07:28:39 -0000 Authentication-Results: pb1.pair.com header.from=php@beccati.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=php@beccati.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain beccati.com designates 176.9.123.236 as permitted sender) X-PHP-List-Original-Sender: php@beccati.com X-Host-Fingerprint: 176.9.123.236 box.beccati.com Received: from [176.9.123.236] ([176.9.123.236:34487] helo=box.beccati.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/2E-09857-02C6DF95 for ; Sat, 04 Nov 2017 02:28:34 -0500 Received: from authenticated-user (box.beccati.com [176.9.123.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by box.beccati.com (Postfix) with ESMTPSA id 1BC9D2000FF; Sat, 4 Nov 2017 08:28:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=beccati.com; s=mail; t=1509780510; bh=0qtykz67t3syjXAxw/mq9Sfc5gg91/zq6LCj+fFC6Sk=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=SQIaIcfn84Swu7w57/SsXXt1grRWKIur6jO8AUiqaCydn67Ihicn91tOPm3rcDoK2 G6eP36Exj+6OuAHcixDTSvUcgpC7xobLS9lJztFlF5NUAsAxADkbH/DKiGwuZ09cx8 hqcgIT7OJxLzy9ox04wWrlkzCjXNPO6cu0E8VGrhhRgLIIswm0738ZsmMqdQT3w9U4 sGTnz1LWNi5DL4UvdKWjCCQk83xf/syNxep1RiYy3lnTf7ssCnVNHPQpNiqQt8xvd0 3GDyx8W8gLyQsPZM39qljGiUUU4U0w0glmILK21Yui3tXslfHKuR9D5WS3jzXJjrUu Iyi2dS2evcFKg== To: Scott Arciszewski Cc: PHP Internals References: <7e7d69c9-8383-9cd0-9a54-0e7e4bb80775@beccati.com> Message-ID: <513ec8cf-6690-0bfa-bf20-b3a38620036b@beccati.com> Date: Sat, 4 Nov 2017 08:28:25 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Idea: PDO - Single-round-trip prepared statements From: php@beccati.com (Matteo Beccati) Hi, On 03/11/2017 21:25, Scott Arciszewski wrote: > ​MySQL calls it an X Protocol, apparently. > > https://dev.mysql.com/doc/internals/en/x-protocol-use-cases-use-cases.html#x-protocol-use-cases-prepared-statements-with-single-round-trip OK, which is something that neither libmysqlclient nor mysqlnd seem to support. > We don't want to disable prepared statements (that constant's name is > somewhat scary). Well, in my experience there are very few occasions that actually benefit from prepared queries. I know it can sound scary, but I do believe that more than 95% of the times prepared queries are just wasting resources. The few patterns that actually benefit from them could just enable them temporarily. Not ideal, but we are kinda used to it with PDO, aren't we? > We don't want to emulate prepared statements (although we'll probably > have to respect the current configuration). At the very least we should turn it off as a default on MySQL. > We just need a separate method (my proposed safeQuery() being distinct > from prepare()) that uses whatever that driver's single-round-trip > prepare-and-execute equivalent API is. If none is available for the > given driver, we need to decide whether to: > > 1. Throw a PDOException, or > 2. Silently use two round trips in the background so it "just works" > even if it's a slight performance hit > > ​(In case it wasn't clear, I'm very much NOT a fan of emulated prepares, > and in EasyDB we go out of our way to disable this feature.) I'm not opposed to a new method, but I think it would be confusing. Moreover with safeQuery you'd miss all the possibilities to bind parameters etc, offered by PDOStatement. Cheers -- Matteo Beccati Development & Consulting - http://www.beccati.com/