RE: mssql_* overhead

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi phillip...

just to clarify regarding having the mysql resource ID in a session var. are
you saying that you're able to more or less, do a mysql_connect and store
the resourceID in a session var, which can then be used on any given page
within your site, without having to recall the mysql_connect to establish a
new connection?

at one time, i had played with how this might be accomplished, and could
never get it to work, without having to get into the idea/area of connection
pools...

thanks for the clarification.



-----Original Message-----
From: Philip Thompson [mailto:prthomp@xxxxxxxx]
Sent: Wednesday, January 10, 2007 9:28 AM
To: php General List
Subject: Re:  mssql_* overhead


I just wanted to make sure that there is no speed decrease if I
change from $_SESSION to $GLOBALS to hold my connection (even with
lots of people). I guess that's my question?

Thanks,
~Philip


On Jan 10, 2007, at 11:01 AM, tg-php@xxxxxxxxxxxxxxxxxxxxxx wrote:

> I thought the same thing as Jochem... that resources like database
> connections, couldn't be stored in $_SESSION. You say that's how
> you have (had?) it set up and it was working, but still sounds
> wrong to me.
>
> As for connections.. definitely don't open a new connection every
> time you run a function, unless it's run so rarely that it makes it
> more efficient to open and close within the function.   If it's a
> function run many times, you're definitely going to see a
> performance hit.
>
> Typical procedure (at least how I've seen it done and done it
> myself at a few different jobs) is to open the connection once and
> close it once.  Which sounds like what you're doing now.
>
> So was your question answered?   Sounds like there's still some
> lingering questions or curiosities...
>
> -TG
>
> = = = Original message = = =
>
> On Jan 10, 2007, at 10:09 AM, Jochem Maas wrote:
>
>> Philip Thompson wrote:
>>> Hi.
>>>
>>> Does anyone know if the mssql_connect/_init/_bind/etc require a
>>> lot of
>>> overhead?
>>>
>>> I have a page that requires multiple function calls and each of
>>> those
>>> opens a new connection to the database, performs the necessary
>>> actions
>>> in stored procedure(s), and then closes the connection. However, I
>>> found
>>> this to be slower than I was wanting. So I thought, just create one
>>> connection and assign it to the SESSION (a global), and in each
>>> function
>>> that requires a connection, call that SESSION variable. At the
>>> end of
>>> the page, close the connection and nullify the variable.
>>
>> I wouldn't stick it in the SESSION superglobal (my tactic is
>> usually to create
>> a little wrapper class to the relevant DB functions and store the
>> connection
>> as a property of the class/object.
>>
>> basically opening & closing the connection once per request is the
>> way to
>> go - if your going to using a global, better [than $_SESSION] to
>> stick it
>> in $GLOBALS imho.
>
> Would there be any speed decrease with multiple users (hundreds)
> sharing this $GLOBALS variable (if that makes sense)?
>
>
>> $_SESSION is used for persisting data over multiple requests -
>> something that
>> is not possible to do for 'resource identifiers' (which is what the
>> connection [id] is).
>
> BTW, it does work b/c that's how it's currently setup. I am open to
> changing it though. I should say, I'm creating at the beginning of
> the script and closing it at the end. So, it doesn't actually stay
> open throughout the whole user session.
>
>
>>> Does anyone see a problem with doing it this way? Security concerns?
>>> Anything?
>>>
>>> Thanks in advance,
>>> ~Philip

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux