par
yann18 » 30 nov. 2013, 17:34
ta pagination est faite côté client(js) donc n'a aucun impact sur la performance de ta requête qui doit toujours retourner 5k lignes.Or c'est au niveau du serveur mysql quil faut restreindre, avec la clause LIMIT, la plage de lignes à afficher.Par exemple, tu veux afficher 10 lignes par page:
//Pour la page 1:
$sql="SELECT a.id_adh, a.nom_adh, a.prenom_adh, a.tel_adh, a.etat_adh, f.id_fact, f.date_fact, f.duree_fact, f.montant_fact, f.id_adh_fact FROM adherents a JOIN facture f ON f.id_adh_fact = a.id_adh ORDER BY date_fact DESC LIMIT 0,10 ";
//Pour la page 2:
$sql="SELECT a.id_adh, a.nom_adh, a.prenom_adh, a.tel_adh, a.etat_adh, f.id_fact, f.date_fact, f.duree_fact, f.montant_fact, f.id_adh_fact FROM adherents a JOIN facture f ON f.id_adh_fact = a.id_adh ORDER BY date_fact DESC LIMIT 10,10 ";
//Pour la page n:
$sql="SELECT a.id_adh, a.nom_adh, a.prenom_adh, a.tel_adh, a.etat_adh, f.id_fact, f.date_fact, f.duree_fact, f.montant_fact, f.id_adh_fact FROM adherents a JOIN facture f ON f.id_adh_fact = a.id_adh ORDER BY date_fact DESC LIMIT (n-1)*10,10 ";
en complément avec tout ce qui a été dit plus haut, tu peux prévoir la mise en place d'un cache côté serveur et d'un cache client.Le cache serveur permet d'éviter de générer des pages dynamiques entre plusieurs appels à condition que ces dernières ne changent pas d'un appel à l'autre. Le cache client quant à lui permet d’éviter au serveur de générer encore une nouvelle page au prochain appel pour le même navigateur.
ta pagination est faite côté client(js) donc n'a aucun impact sur la performance de ta requête qui doit toujours retourner 5k lignes.Or c'est au niveau du serveur mysql quil faut restreindre, avec la clause LIMIT, la plage de lignes à afficher.Par exemple, tu veux afficher 10 lignes par page:
[php]
//Pour la page 1:
$sql="SELECT a.id_adh, a.nom_adh, a.prenom_adh, a.tel_adh, a.etat_adh, f.id_fact, f.date_fact, f.duree_fact, f.montant_fact, f.id_adh_fact FROM adherents a JOIN facture f ON f.id_adh_fact = a.id_adh ORDER BY date_fact DESC LIMIT 0,10 ";
//Pour la page 2:
$sql="SELECT a.id_adh, a.nom_adh, a.prenom_adh, a.tel_adh, a.etat_adh, f.id_fact, f.date_fact, f.duree_fact, f.montant_fact, f.id_adh_fact FROM adherents a JOIN facture f ON f.id_adh_fact = a.id_adh ORDER BY date_fact DESC LIMIT 10,10 ";
//Pour la page n:
$sql="SELECT a.id_adh, a.nom_adh, a.prenom_adh, a.tel_adh, a.etat_adh, f.id_fact, f.date_fact, f.duree_fact, f.montant_fact, f.id_adh_fact FROM adherents a JOIN facture f ON f.id_adh_fact = a.id_adh ORDER BY date_fact DESC LIMIT (n-1)*10,10 ";
[/php]
en complément avec tout ce qui a été dit plus haut, tu peux prévoir la mise en place d'un cache côté serveur et d'un cache client.Le cache serveur permet d'éviter de générer des pages dynamiques entre plusieurs appels à condition que ces dernières ne changent pas d'un appel à l'autre. Le cache client quant à lui permet d’éviter au serveur de générer encore une nouvelle page au prochain appel pour le même navigateur.