IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

temps d'accès et base de donnée mysql


Sujet :

PHP & Base de données

  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    200
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 200
    Par défaut temps d'accès et base de donnée mysql
    Bonjour,

    Je suis entrain d'optimiser un site web que je reprends et qui n'est pas documenté! Le but est de réduire le temps de chargement.

    Pour cela, entre autres, je dois diminuer des temps d'accès à la base de données.

    Question1: Y a t il un moyen (scripts, outils ou astuces) pour recencer tous les accès à la base de donnée?
    Question 2: est ce que la déconnexion de la base de donnée après chaque interrogation permet de gagner du temps de chargement des pages web?
    Pour la question 1: par exemple, je pense à rajouter du code dans les méthodes de la classe qui manipule la base de donnée.

    Merci

  2. #2
    Modérateur
    Avatar de grunk
    Homme Profil pro
    Lead dév - Architecte
    Inscrit en
    Août 2003
    Messages
    6 693
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Lead dév - Architecte
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2003
    Messages : 6 693
    Par défaut
    Es tu certain que ce sont les temps d'accès à la base qui sont long et non pas son temps de réponse ?

    Parce que au niveau temps d'accès y'a pas grand chose à faire pour optimiser. En revanche au niveau temsp de réponse de la base , y'a moulte chose possible. (optimisation des requetes , des tables ...)

    Question 1 : Pas d'astuce en particulier , comme tu le penses un log dans ta classe semble être la bonne solution.

    Question 2 : Connexion dès que tu as besoin d'effectuer une requete , deconnexion en fin de script. Si tu ouvre et ferme une connexion à chaque requete ca va forcément te ralentir.
    Pry Framework php5 | N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  3. #3
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Par défaut
    Tu peux réaliser un Profiling de ton script avec XDebug afin de voir precisemment quelles parties sont lentes.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  4. #4
    Membre éclairé
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    200
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 200
    Par défaut comment optimiser le temps de réponse?
    Bonjour,

    En revanche au niveau temsp de réponse de la base , y'a moulte chose possible. (optimisation des requetes , des tables ...)
    comment optimiser le temps de réponse?


    Tu peux réaliser un Profiling de ton script avec XDebug afin de voir precisemment quelles parties sont lentes.
    Pour Xdebug merci beacoup je vais le teseter!

    Merci

  5. #5
    Modérateur
    Avatar de grunk
    Homme Profil pro
    Lead dév - Architecte
    Inscrit en
    Août 2003
    Messages
    6 693
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Lead dév - Architecte
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2003
    Messages : 6 693
    Par défaut
    comment optimiser le temps de réponse?
    En utilisant judicieusement des index par exemple , en ayant une Bdd bien structuré...

    Pour te donner une idée tu peux passer en revue tes requetes avec un EXPLAIN devant une requête.

    Une requête de selection ne doit par exemple pas parcourir toutes les lignes d'une table poour trouver ce qu'elle recherche. C'est là qu'interviennent les index.
    Pry Framework php5 | N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  6. #6
    Membre éclairé
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    200
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 200
    Par défaut optimisation code joomla
    Merci je vais tester

    le code que je suis entrain d'optimiser est un code joomla modifé!

    Voila, si quelqu'un a déjà fait ça?

    Merci

  7. #7
    Membre éclairé
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    200
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 200
    Par défaut utilisation xdebug
    Bonjour,
    je n'arrive pas à utiliser xdebug!


    Voici la page de telechargement des sources et dll

    http://www.xdebug.org/download.php


    Xdebug
    XDEBUG EXTENSION FOR PHP | DOWNLOADS
    home | updates | obtaining | documentation | license | support


    Source

    Xdebug is hosted in CVS. The source code can be browsed through ViewVC and can be checkout with:

    cvs -d :pserver:srmread@cvs.xdebug.org:/repository login
    # password= srmread
    cvs -d :pserver:srmread@cvs.xdebug.org:/repository co xdebug

    You can also checkout the 2.0 branch with:

    cvs -d :pserver:srmread@cvs.xdebug.org:/repository co -r xdebug_2_0 xdebug

    Releases

    The Windows binaries generally work for every mini release for the mentioned PHP version, although the extension is built against the most current PHP version at that time. The VCx marker tells with which compiler the extension was built, and Non-thread-safe whether ZTS was disabled. Those qualifiers need to match the PHP version you're using.
    Xdebug 2.0.4
    Release date: 2008-12-30

    * source
    * Windows binaries: 5.2 VC6 Non-thread-safe, 5.2 VC6, 5.3 VC6 Non-thread-safe, 5.3 VC6, 5.3 VC9 Non-thread-safe, 5.3 VC9

    Xdebug 2.0.3
    Release date: 2008-04-11

    * source
    * Windows binaries: 5.1 VC6, 5.2 VC6, 5.3 VC6

    Xdebug 2.0.2
    Release date: 2007-11-11

    * source
    * Windows binaries: 4.4 VC6, 5.1 VC6, 5.2 VC6, 5.3 VC6

    Xdebug 2.0.1
    Release date: 2007-10-21

    * source
    * Windows binaries: 4.4 VC6, 5.1 VC6, 5.2 VC6

    Xdebug 2.0.0
    Release date: 2007-07-18

    * source
    * Windows binaries: 4.4 VC6, 5.1 VC6, 5.2 VC6

    Xdebug 1.3.2
    Release date: 2004-06-30

    * source

    Xdebug 1.3.1
    Release date: 2004-04-06

    * source



    This site and all of its contents are Copyright © 2002-2009 by Derick Rethans.
    All rights reserved.
    Voici l'aide
    http://www.xdebug.org/docs/install

    Xdebug
    XDEBUG EXTENSION FOR PHP | DOCUMENTATION
    home | updates | download | documentation | license | support

    » Documentation for: Xdebug 2
    » Feature: Installation

    This section describes on how to install Xdebug.
    Precompiled Modules

    There are a few precompiled modules for Windows, they are all for the non-debug version of PHP. See the links on the right side.

    Installing the precompiled modules is easy. Just place them in a directory, and add the following line to php.ini: (don't forget to change the path and filename to the correct one — but make sure you use the full path)

    zend_extension_ts="c:/php/modules/php_xdebug-4.4.1-2.0.2.dll"

    PECL Installation

    As of Xdebug 0.9.0 you can install Xdebug through PEAR/PECL. This only works with with PEAR version 0.9.1-dev or higher and some UNIX.

    Installing with PEAR/PECL is as easy as:

    # pecl install xdebug

    but you still need to add the correct line to your php.ini: (don't forget to change the path and filename to the correct one — but make sure you use the full path)

    zend_extension="/usr/local/php/modules/xdebug.so"

    Installation From Source

    You can download the source of the latest stable release 2.0.2. Alternatively you can obtain Xdebug from CVS:

    cvs -d :pserver:srmread@cvs.xdebug.org:/repository login
    CVS password: srmread
    cvs -d :pserver:srmread@cvs.xdebug.org:/repository co xdebug

    This will checkout the latest development version which is currently 2.1.0-dev. You can also browse the source at http://cvs.xdebug.org.
    Compiling

    You compile Xdebug separately from the rest of PHP. Note, however, that you need access to the scripts 'phpize' and 'php-config'. If your system does not have 'phpize' and 'php-config', you will need to compile and install PHP from a source tarball first, as these script are by-products of the PHP compilation and installation processes. (Debian users can install the required tools with apt-get install php4-dev, or apt-get install php5-dev). It is important that the source version matches the installed version as there are slight, but important, differences between PHP versions. Once you have access to 'phpize' and 'php-config', do the following:

    1. Unpack the tarball: tar -xzf xdebug-2.0.2.tgz. Note that you do not need to unpack the tarball inside the PHP source code tree. Xdebug is compiled separately, all by itself, as stated above.
    2. cd xdebug-2.0.2
    3. Run phpize: phpize (or /path/to/phpize if phpize is not in your path). See in the table below which version numbers it should show for different PHP versions. Make sure you use the phpize that belongs to the PHP version that you want to use Xdebug with.
    4. ./configure --enable-xdebug (or: ./configure --enable-xdebug --with-php-config=/path/to/php-config if php-config is not in your path).

    If this fails with something like:

    ../configure: line 1960: syntax error near unexpected token
    `PHP_NEW_EXTENSION(xdebug,'
    ../configure: line 1960: ` PHP_NEW_EXTENSION(xdebug, xdebug.c
    xdebug_code_coverage.c xdebug_com.c xdebug_handler_gdb.c
    xdebug_handler_php3.c xdebug_handlers.c xdebug_llist.c xdebug_hash.c
    xdebug_profiler.c xdebug_superglobals.c xdebug_var.c usefulstuff.c,
    $ext_shared)'

    then it means that you do not meet the PHP 4.3.x version requirement for Xdebug.

    Another problem that might occur is:

    configure: line 1145: PHP_INIT_BUILD_SYSTEM: command not found
    configure: line 1151: syntax error near unexpected token `config.nice'
    configure: line 1151: `PHP_CONFIG_NICE(config.nice)'

    You will need to upgrade your autotools (autoconf, automake and libtool) or install the known working versions: autoconf-2.13, automake-1.5 and libtool-1.4.3.
    5. make
    6. cp modules/xdebug.so /to/wherever/you/want/it

    Configure PHP to Use Xdebug

    1. add the following line to php.ini: zend_extension="/wherever/you/put/it/xdebug.so" (for non-threaded use of PHP, for example the CLI, CGI or Apache 1.3 module) or: zend_extension_ts="/wherever/you/put/it/xdebug.so" (for threaded usage of PHP, for example the Apache 2 work MPM or the the ISAPI module). Note: In case you compiled PHP yourself and used --enable-debug you would have to use zend_extension_debug=.
    2. Restart your webserver.
    3. Write a PHP page that calls 'phpinfo()' Load it in a browser and look for the info on the Xdebug module. If you see it next to the Zend logo, you have been successful! You can also use 'php -m' if you have a command line version of PHP, it lists all loaded modules. Xdebug should appear twice there (once under 'PHP Modules' and once under 'Zend Modules').

    Compatibility

    Xdebug does not work together with the Zend Optimizer or any other Zend extension (DBG, APD etc). This is due to compatibility problems with those modules. We will be working on figuring out what the problems are, and of course try to fix those.
    phpize Output Table

    PHP Version: PHP Api Version: Zend Module Api No: Zend Extension Api No: Recommended version:
    4.4.x 20020918 20020429 20050606 2.0.2
    5.1.x 20041225 20050922 220051025 2.0.2
    5.2.x 20041225 20060613 220060519 2.0.2

    Debugclient Installation

    Unpack the Xdebug source tarball and issue the following commands:

    $ cd debugclient
    $ ./configure --with-libedit
    $ make
    # make install

    This will install the debugclient binary in /usr/local/bin unless you don't have libedit installed on your system. You can either install it, or leave out the '--with-libedit' option to configure. Debian 'unstable' users can install the library with apt-get install libedit-dev libedit2.

    If the configure script can not find libedit and you are sure you have (and it's headers) installed correctly and you get link errors like the following in your configure.log:

    /usr/lib64/libedit.so: undefined reference to `tgetnum'
    /usr/lib64/libedit.so: undefined reference to `tgoto'
    /usr/lib64/libedit.so: undefined reference to `tgetflag'
    /usr/lib64/libedit.so: undefined reference to `tputs'
    /usr/lib64/libedit.so: undefined reference to `tgetent'
    /usr/lib64/libedit.so: undefined reference to `tgetstr'
    collect2: ld returned 1 exit status

    you need to change your configure command to:

    $ LDFLAGS=-lncurses ./configure --with-libedit



    This site and all of its contents are Copyright © 2002-2009 by Derick Rethans.
    All rights reserved.

Discussions similaires

  1. Accés à une base de données Mysql
    Par astrotouf dans le forum Glassfish et Payara
    Réponses: 4
    Dernier message: 19/01/2009, 11h10
  2. [Portlet] portlet avec un accès à une base de donné mysql
    Par prodit96 dans le forum Portails
    Réponses: 1
    Dernier message: 12/01/2009, 15h41
  3. [MySQL] Accés à une base de données MySQL
    Par apt dans le forum PHP & Base de données
    Réponses: 4
    Dernier message: 06/10/2008, 19h35
  4. Accès à une base de données MySQL
    Par cybernikkos dans le forum C++Builder
    Réponses: 2
    Dernier message: 18/05/2007, 22h03
  5. [JDBC]acces à une base de données mysql
    Par sehaba dans le forum JDBC
    Réponses: 13
    Dernier message: 07/12/2004, 00h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo