FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Mysqli or PDO Persistent prepared statements
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Mysqli or PDO Persistent prepared statements [message #183644] Wed, 06 November 2013 09:18 Go to next message
ram is currently offline  ram
Messages: 4
Registered: February 2011
Karma: 0
Junior Member
I have a very high traffic server. Getting upto a million hits per day.
These are basically tracking URLs that log the hits and redirect to the relevant page

The current script using php mysql is very slow. I want to switch to mysqli.
Are there any basic guidelines for shifting to mysqli
Can I use a persistent prepared statements across different calls to the web server ?

Thanks
Ram
Spammers please visit http://pragatee.com
Re: Mysqli or PDO Persistent prepared statements [message #183645 is a reply to message #183644] Wed, 06 November 2013 09:46 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 06/11/13 09:18, Ram wrote:
> I have a very high traffic server. Getting upto a million hits per day.
> These are basically tracking URLs that log the hits and redirect to the relevant page
>
> The current script using php mysql is very slow. I want to switch to mysqli.

I doubt that will make any difference

> Are there any basic guidelines for shifting to mysqli
> Can I use a persistent prepared statements across different calls to the web server ?
>
> Thanks
> Ram
> Spammers please visit http://pragatee.com
>


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
Re: Mysqli or PDO Persistent prepared statements [message #183646 is a reply to message #183644] Wed, 06 November 2013 10:45 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 11/6/2013 4:18 AM, Ram wrote:
> I have a very high traffic server. Getting upto a million hits per day.
> These are basically tracking URLs that log the hits and redirect to the relevant page
>
> The current script using php mysql is very slow. I want to switch to mysqli.
> Are there any basic guidelines for shifting to mysqli
> Can I use a persistent prepared statements across different calls to the web server ?
>
> Thanks
> Ram
> Spammers please visit http://pragatee.com
>

You're not going to see any significant gain by switching from
mysql_xxx() to mysqli_xxx(). Both use similar interfaces, and the
overhead is about the same.

Prepared statements are good, but they will slow you down even more as
each one requires multiple calls to the database code. MySQL has no
such thing as "persistent prepared statements" (neither does anyone else
AFAIK).

Have you determined your MySQL calls are the problem? Or are you
shooting in the dark?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Mysqli or PDO Persistent prepared statements [message #183652 is a reply to message #183644] Wed, 06 November 2013 17:41 Go to previous messageGo to next message
Tobiah is currently offline  Tobiah
Messages: 30
Registered: April 2011
Karma: 0
Member
> The current script using php mysql is very slow.

Are you good at database administration? Most of the time it's a lack of
indexing in the table definitions. Next up is 'loose' joins that are not
completely constrained between tables. You don't want to see 'Copying to
Temp table' in the process list.
Re: Mysqli or PDO Persistent prepared statements [message #183654 is a reply to message #183644] Wed, 06 November 2013 19:25 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Ram wrote:

> The current script using php mysql is very slow. I want to switch to
> mysqli.

With obsolete code like that, make sure that this is not the only reason for
reduced effiency.

> I want to switch to mysqli.

Good Idea. Also consider PDO_MySQL; PDO has the simpler interface and is
database-agnostic.

> Are there any basic guidelines for shifting to mysqli

Yes.

> Can I use a persistent prepared statements across different calls to the
> web server ?

No.

> Thanks

You're welcome.

> Ram

Belongs beneath “-- ” if there is enough room.

> Spammers please visit http://pragatee.com

You do not seriously expect spammers to read the body of your messages, do
you?


PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7(at)news(dot)demon(dot)co(dot)uk> (2004)
Re: Mysqli or PDO Persistent prepared statements [message #183655 is a reply to message #183644] Wed, 06 November 2013 20:04 Go to previous messageGo to next message
Arno Welzel is currently offline  Arno Welzel
Messages: 317
Registered: October 2011
Karma: 0
Senior Member
Ram, 2013-11-06 10:18:

> I have a very high traffic server. Getting upto a million hits per day.
> These are basically tracking URLs that log the hits and redirect to the relevant page
>
> The current script using php mysql is very slow. I want to switch to mysqli.
> Are there any basic guidelines for shifting to mysqli
> Can I use a persistent prepared statements across different calls to the web server ?

Besides all other tips: Consider using a byte code cache (XCache, APC
etc.) as well and also check if not the database itself is the bottleneck.

A million hits per day may be up to 10 hits per second - and if really
*every* hit results in a database operation it may not just the small
difference between mysql, msqli or PDO which is important here.

Also check your application in a test environment and load/stress
testing tools (ApacheBench, Gatling Curl-loader etc.) to see how your
scripts perform.

Maybe using other techniques may be better - e.g. using a kind of
"cache" for the redirects which can be loaded and used without any
database access at all. If you need to track hits as well it may be
easier to keep process access logs in text form and process them using a
cron job in background and maybe even on another server.


--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
Re: Mysqli or PDO Persistent prepared statements [message #183657 is a reply to message #183654] Wed, 06 November 2013 22:06 Go to previous message
Beauregard T. Shagnas is currently offline  Beauregard T. Shagnas
Messages: 154
Registered: September 2010
Karma: 0
Senior Member
Thomas 'PointedHead' Lahn wrote:

> Ram wrote:
>> Ram
>
> Belongs beneath “-- ” if there is enough room.
>
> PointedEars

Belongs beneath “-- ” if there is enough room.

--
-bts
-Tit for Tat
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: detection of 2d array?
Next Topic: another value passing problem
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 21 16:21:38 GMT 2024

Total time taken to generate the page: 0.02244 seconds