0lav Skrevet 12. juni 2007 Del Skrevet 12. juni 2007 Hei! Jeg har i det siste prøvd å finne ut hva som er lurest å bruke av mysql_connect og mysql_pconnect, og hva de forskjellige fordelene ved disse to er. PHP.net skriver dette om mysql_pconnect: mysql_pconnect() acts very much like mysql_connect() with two major differences. First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection. Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect()). This type of link is therefore called 'persistent'. Jeg har også sett i forumet her at mysql_pconnect kan løse problemer som f.eks. "To many connections.." osv.. Vil det alltså si at mysql_pconnect er best å bruke, spesielt hvis man har mange brukere på siden? Eller hva er egentlig positivt/negativt med mysql_connect iforhold til mysql_pconnect og omvendt? På forhånd takk for svar! Lenke til kommentar
Ståle Skrevet 12. juni 2007 Del Skrevet 12. juni 2007 the more users you have at one time, the more sense it makes to use pconnect. what happens is that when you make a connections with connect, it expires as soon as you're done but if you use pconnect, there is a delay so if you call pconnect again soon and theres already a connection in the pool, it will use that one. the pros and cons are: connect: for many people at once, this makes a lot of connections and slows down the server, but for a few people this is what you want to use because... pconnect: for a few people, you will be adding overhead to the server by leaving the connections active even though noone is using them, but for a lot of people at once, you are saving time on garbage collection by not having to close all the connections. http://php.tribe.net/thread/636f66ad-6253-...01-163e9093846a Lenke til kommentar
0lav Skrevet 12. juni 2007 Forfatter Del Skrevet 12. juni 2007 Takk! Jeg burde kansje ha googlet litt mere selv først.. Men hva vil egentlig "many users" si? Er det et ca. antall som blir regnet for mye, eller har det alt å gjøre med hvor kraftig server du har? Jeg antar det er det siste da.. Lenke til kommentar
Crowly Skrevet 12. juni 2007 Del Skrevet 12. juni 2007 Server kapasitet og hvilke begrensninger hosten har satt vil jeg tro. En host jeg har vært borti har 36000 oppslag i timen som maks grense mot mysql basen. Ellers så er det sikkert ett innslagspunkt hvor den ene blir mer effektiv enn den andre når det kommer til å optimalisere koden. Lenke til kommentar
Anbefalte innlegg
Opprett en konto eller logg inn for å kommentere
Du må være et medlem for å kunne skrive en kommentar
Opprett konto
Det er enkelt å melde seg inn for å starte en ny konto!
Start en kontoLogg inn
Har du allerede en konto? Logg inn her.
Logg inn nå