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 :

Accumulation de requêtes lourdes [MySQL]


Sujet :

PHP & Base de données

  1. #1
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2011
    Messages
    148
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juin 2011
    Messages : 148
    Points : 54
    Points
    54
    Par défaut Accumulation de requêtes lourdes
    Bonjour,

    Je veux faire une page avec plusieurs onglets jquery ... le problème étant qu'il faut charger 5 pages de données ... et c'est long

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
     
    <div id="tabs">
    	<ul>
    		<li><a id="onglet" href="#tabs-1">Joueurs</a></li>
    		<li><a id="onglet" href="#tabs-2">Alliances</a></li>
    		<li><a id="onglet" href="#tabs-3">Combattant</a></li>
    		<li><a id="onglet" href="#tabs-4">Attaquant</a></li>
    		<li><a id="onglet" href="#tabs-5">Défenseur</a></li>
    	</ul>
    	<div id="tabs-1">
    <?php
    $select = "SELECT numero, name FROM infos WHERE name= '".$_GET['monde']."'";
    $result = mysql_query($select,$link_stats) or die ('Erreur : '.mysql_error() );
    $total = mysql_num_rows($result);
     
    if($total) {
        while($row = mysql_fetch_array($result)) {
    $monde=$row["name"];
    $numero_monde=$row["numero"];
        }
     
    }
    else echo 'Ce monde n\'existe pas!';
    mysql_free_result($result);
     
    ?>
    <?php
    $player = mysql_query('SELECT p.id AS id, 
    	p.name, 
    	a.id AS alliance_id, 
    	a.alliance_name AS alliance_name,
    	p.points, 
    	p.rank, 
    	p.towns 
    FROM '.$_GET['monde'].'_players p
    INNER JOIN '.$_GET['monde'].'_alliances a ON (a.id = p.alliance_id)
    ORDER BY rank ASC
    LIMIT 0,10');
    $totalp = mysql_num_rows($player);
     
    if($totalp) {
     
        // debut du tableau
        echo '<table id=mytable>'."\n";
            // premi? ligne on affiche les titres pr?m et surnom dans 2 colonnes
            echo '<tr>';
            echo '<th scope="col"><b><u>Rang</u></b></td>' ;
            echo '<th scope="col"><b><u>Pseudo</u></b></td>';
          echo '<th scope="col"><b><u>Alliance</u></b></td>';
            echo '<th scope="col"><b><u>Points</u></b></td>';
    		echo '<th scope="col"><b><u>Villes</u></b></td>';
          echo '</tr>'."\n";
        // lecture et affichage des r?ltats sur 2 colonnes, 1 r?ltat par ligne.    
        while($row = mysql_fetch_array($player)) {
            echo '<tr>';
            echo '<td scope="row">'.$row["rank"].'</td>';
            echo '<td scope="row"><a href="'.append_sid('player/'.$monde.'/'.$row["id"]).'">'.urldecode($row["name"]).'</a></td>';
            echo '<td scope="row"><a href="'.append_sid('alliance/'.$monde.'/'.$row["alliance_id"]).'">'.urldecode($row["alliance_name"]).'</a></td>';
          echo '<td scope="row">'.$english_format_number = number_format($row["points"]).'</td>';
    	  echo '<td scope="row">'.$row["towns"].'</td>';
          echo '</tr>'."\n";
        }
        echo '</table>'."\n";
        // fin du tableau.
     
     
     
    }
    else echo 'Pas d\'enregistrements dans cette table...';
    // on lib‚re le r‚sultat
    mysql_free_result($player);
    ?>
    </div>
    	<div id="tabs-2">
    <?php
    $alliance = mysql_query('SELECT a.id AS id, 
    	a.alliance_name	, 
    	a.points, 
    	a.rank, 
    	a.villages,
    	a.members 
    FROM '.$_GET['monde'].'_alliances a
    ORDER BY rank ASC
    LIMIT 0,10');
    $totala = mysql_num_rows($alliance);
     
    if($totala) {
     
        // debut du tableau
        echo '<table id=mytable>'."\n";
            // premi? ligne on affiche les titres pr?m et surnom dans 2 colonnes
            echo '<tr>';
            echo '<th scope="col"><b><u>Rang</u></b></td>' ;
            echo '<th scope="col"><b><u>Nom</u></b></td>';
    		echo '<th scope="col"><b><u>Points</u></b></td>';
            echo '<th scope="col"><b><u>Membres</u></b></td>';
            echo '<th scope="col"><b><u>Villes</u></b></td>';
    		echo '<th scope="col"><b><u>Moy. membres</u></b></td>';
    		echo '<th scope="col"><b><u>Moy.villes</u></b></td>';
            echo '</tr>'."\n";
        // lecture et affichage des r?ltats sur 2 colonnes, 1 r?ltat par ligne.    
        while($row = mysql_fetch_array($alliance)) {
     
    	$average_cities_points=$row["points"] / $row["villages"];
    	$average_members_points=$row["points"] / $row["members"];
     
            echo '<tr>';
            echo '<td scope="row">'.$row["rank"].'</td>';
            echo '<td scope="row"><a href="'.append_sid('alliance/'.$monde.'/'.$row["id"]).'">'.urldecode($row["alliance_name"]).'</a></td>';
            echo '<td scope="row">'.$english_format_number = number_format($row["points"]).'</a></td>';
            echo '<td scope="row">'.$row["members"].'</td>';
    	    echo '<td scope="row">'.$english_format_number = number_format($row["villages"]).'</td>';
    	    echo '<td scope="row">'.$english_format_number = number_format($average_members_points).'</td>';
    	    echo '<td scope="row">'.$english_format_number = number_format($average_cities_points).'</td>';
            echo '</tr>'."\n";
        }
        echo '</table>'."\n";
        // fin du tableau.
     
     
     
    }
    else echo 'Pas d\'enregistrements dans cette table...';
    // on lib‚re le r‚sultat
    mysql_free_result($alliance);
    ?>
    	</div>
    	<div id="tabs-3">
    <?php
    $combattant = mysql_query('SELECT a.rank, 
    	a.player_id	, 
    	a.points,
    	p.id AS id,
    	p.name AS name
    FROM '.$_GET['monde'].'_player_kills_all a
    LEFT JOIN '.$_GET['monde'].'_players p ON (p.id=a.player_id)
    ORDER BY rank ASC
    LIMIT 0,10');
    $totalc = mysql_num_rows($combattant);
     
    if($totalc) {
     
        // debut du tableau
        echo '<table id=mytable>'."\n";
            // premi? ligne on affiche les titres pr?m et surnom dans 2 colonnes
            echo '<tr>';
            echo '<th scope="col"><b><u>Rang</u></b></td>' ;
            echo '<th scope="col"><b><u>Nom</u></b></td>';
    		echo '<th scope="col"><b><u>Points</u></b></td>';
            echo '</tr>'."\n";
        // lecture et affichage des r?ltats sur 2 colonnes, 1 r?ltat par ligne.    
        while($row = mysql_fetch_array($combattant)) {
     
            echo '<tr>';
            echo '<td scope="row">'.$row["rank"].'</td>';
            echo '<td scope="row"><a href="'.append_sid('player/'.$monde.'/'.$row["id"]).'">'.urldecode($row["name"]).'</a></td>';
            echo '<td scope="row">'.$english_format_number = number_format($row["points"]).'</a></td>';
          echo '</tr>'."\n";
        }
        echo '</table>'."\n";
        // fin du tableau.
     
     
     
    }
    else echo 'Pas d\'enregistrements dans cette table...';
     
    mysql_free_result($combattant);
    ?>	
    	</div>
     
    <div id="tabs-4">	
    <?php
    $attaquant = mysql_query('SELECT a.rank, 
    	a.player_id	, 
    	a.points,
    	p.id AS id,
    	p.name AS name
    FROM '.$_GET['monde'].'_player_kills_att a
    LEFT JOIN '.$_GET['monde'].'_players p ON (p.id=a.player_id)
    ORDER BY rank ASC
    LIMIT 0,10');
    $totalat = mysql_num_rows($attaquant);
     
    if($totalat) {
     
        // debut du tableau
        echo '<table id=mytable>'."\n";
            // premi? ligne on affiche les titres pr?m et surnom dans 2 colonnes
            echo '<tr>';
            echo '<th scope="col"><b><u>Rang</u></b></td>' ;
            echo '<th scope="col"><b><u>Nom</u></b></td>';
    		echo '<th scope="col"><b><u>Points</u></b></td>';
            echo '</tr>'."\n";
        // lecture et affichage des r?ltats sur 2 colonnes, 1 r?ltat par ligne.    
        while($row = mysql_fetch_array($attaquant)) {
     
            echo '<tr>';
            echo '<td scope="row">'.$row["rank"].'</td>';
            echo '<td scope="row"><a href="'.append_sid('player/'.$monde.'/'.$row["id"]).'">'.urldecode($row["name"]).'</a></td>';
            echo '<td scope="row">'.$english_format_number = number_format($row["points"]).'</a></td>';
          echo '</tr>'."\n";
        }
        echo '</table>'."\n";
        // fin du tableau.
     
     
     
    }
    else echo 'Pas d\'enregistrements dans cette table...';
     
    mysql_free_result($attaquant);
    ?>	
    	</div>
    <div id="tabs-5">
    <?php
    $defenseur = mysql_query('SELECT a.rank, 
    	a.player_id	, 
    	a.points,
    	p.id AS id,
    	p.name AS name
    FROM '.$_GET['monde'].'_player_kills_def a
    LEFT JOIN '.$_GET['monde'].'_players p ON (p.id=a.player_id)
    ORDER BY rank ASC
    LIMIT 0,10');
    $totald = mysql_num_rows($defenseur);
     
    if($totald) {
     
        // debut du tableau
        echo '<table id=mytable>'."\n";
            // premi? ligne on affiche les titres pr?m et surnom dans 2 colonnes
            echo '<tr>';
            echo '<th scope="col"><b><u>Rang</u></b></td>' ;
            echo '<th scope="col"><b><u>Nom</u></b></td>';
    		echo '<th scope="col"><b><u>Points</u></b></td>';
            echo '</tr>'."\n";
        // lecture et affichage des r?ltats sur 2 colonnes, 1 r?ltat par ligne.    
        while($row = mysql_fetch_array($defenseur)) {
     
            echo '<tr>';
            echo '<td scope="row">'.$row["rank"].'</td>';
            echo '<td scope="row"><a href="'.append_sid('player/'.$monde.'/'.$row["id"]).'">'.urldecode($row["name"]).'</a></td>';
            echo '<td scope="row">'.$english_format_number = number_format($row["points"]).'</a></td>';
          echo '</tr>'."\n";
        }
        echo '</table>'."\n";
        // fin du tableau.
     
     
     
    }
    else echo 'Pas d\'enregistrements dans cette table...';
     
    mysql_free_result($defenseur);
    ?>	
    	</div>
    </div>
    Comment allèger tout ça ?

  2. #2
    Expert éminent sénior
    Avatar de rawsrc
    Homme Profil pro
    Dev indep
    Inscrit en
    Mars 2004
    Messages
    6 142
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Dev indep

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 142
    Points : 16 545
    Points
    16 545
    Billets dans le blog
    12
    Par défaut
    Citation Envoyé par MRJBGO Voir le message
    Comment allèger tout ça ?
    Simple, au lieu de tout charger, il faut juste te limiter à n'afficher et (donc charger) que l'onglet en cours de visualisation.

    Voilà, voilà...

  3. #3
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2011
    Messages
    148
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juin 2011
    Messages : 148
    Points : 54
    Points
    54
    Par défaut
    Très bien, c'est ce que je pensais ^^

    Comment n'en charger qu'un ?

  4. #4
    Membre régulier Avatar de LeGnome12
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mai 2008
    Messages
    98
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Mai 2008
    Messages : 98
    Points : 109
    Points
    109
    Par défaut
    Salut,
    Peut-être que tu trouveras ta réponse du côté de l'Ajax.

  5. #5
    Membre actif
    Inscrit en
    Décembre 2009
    Messages
    282
    Détails du profil
    Informations forums :
    Inscription : Décembre 2009
    Messages : 282
    Points : 286
    Points
    286
    Par défaut
    oui jquery ui tabs permet de charger par ajax, tu devrais regarder sur leur site, ils ont des exemples concrets si je me rappelle bien !

  6. #6
    Membre actif
    Inscrit en
    Décembre 2009
    Messages
    282
    Détails du profil
    Informations forums :
    Inscription : Décembre 2009
    Messages : 282
    Points : 286
    Points
    286
    Par défaut
    Plus précisément sur cette URL, ils expliquent comment paramêtrer avec les attributs "href" !!

  7. #7
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2011
    Messages
    148
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juin 2011
    Messages : 148
    Points : 54
    Points
    54
    Par défaut
    Et en plus, j'étais sur la page

    Merci beaucoup !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Optimiser une requête lourde
    Par Sango64 dans le forum Langage SQL
    Réponses: 20
    Dernier message: 21/06/2013, 15h46
  2. Optimiser requête lourde (Copying to tmp table ?)
    Par JerryOne3 dans le forum Requêtes
    Réponses: 2
    Dernier message: 20/09/2011, 10h13
  3. Choix alerte SQL // requêtes lourdes
    Par remi.journet dans le forum Administration
    Réponses: 4
    Dernier message: 08/09/2011, 09h14
  4. Optimisation requête lourde
    Par Shinosha dans le forum Débuter
    Réponses: 7
    Dernier message: 03/07/2011, 07h14
  5. Comment optimiser une lourde requête avec des index
    Par Romalafrite dans le forum Requêtes
    Réponses: 10
    Dernier message: 01/12/2006, 19h18

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